NHibernate has the facility to map integer columns in the database to enum values in your objects. However, the NHibernate Designer doesn’t automatically know about your enum types, so by default you won’t find your enum types in the Data Type drop-down. So if you want to map a column an enum, how do you do it?
The answer is that you need to tell the NHibernate Designer about your enum type, which you can do through the NHibernate Model Explorer. To open the NHibernate Model Explorer if it’s not already open, choose View > Other Windows > NHibernate Model. You’ll see a tree display of your model.
Now right-click the Model node and choose Add New Enum Type. Then enter the full enum type name, and the name by which you want to refer to the enum in the Data Type drop-down:
Now you can use the enum type in your entity properties just as if it were a built-in type:
Download the NHibernate designer today — or install it directly through the VS2010 Extension Manager — and check it out!