Search code examples
nhibernatefluent-nhibernatenhibernate-mappingfluent-nhibernate-mapping

Difference between FluentNHibernate and NHibernate's "Mapping by Code"


I am coming from an Entity Framework and LLBL background for my ORM tools.

I have been asked to build a new system based on NHibernate. I have never done so, so I am coming at it with fresh eyes.

What is the difference between mapping with Fluent NHibernate and "Mapping By Code" in NHibernate? Is there a preference?


Solution

  • Fluent NH

    Fluent NHibernate offers an alternative to NHibernate's standard XML mapping files. Rather than writing XML documents, you write mappings in strongly typed C# code. This allows for easy refactoring, improved readability and more concise code.

    vs.

    NH's new mapping by code

    It is an XML-less mapping solution being an integral part of NHibernate since 3.2, based on ConfORM library. Its API tries to conform to XML naming and structure. There's a strong convention in how the mapping methods are built. Its names are almost always equal to XML elements names.