Topic: NHibernate

NHibernate Built-in Code Based Mapping instead of using Fluent NHibernate

This is just a quick post to show how to use the new NHibernate built-in mapping instead of using Fluent NHibernate. It looks like the Fluent Hibernate is not compatible with the latest version of NHibernate that is available in NuGet. Although I am a fan of Fluent NHibernate but I am not sure about it’s future as the core NHibernate now has this similar kind of code based mapping instead of those boring xml files. I will show you the Fluent NHibernate Mapping first then the new mapping. This is extracted from one of my pet project that I am using to play with jQuery Mobile and Spine. Lets say I have a basic User object which was mapped in Fluent NHibernate like the following: