Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Fluent NHibernate vs. hbm XML files?

While this is a subjective question, as a new NHibernate user, I'm curious as to why one would choose Fluent vs traditional XML mapping.

From my standpoint, when I first worked with NHibernate, I used the Fluent interface, but ran into some roadblocks and had a hard time finding adequate documentation for the Fluent interface for anything beyond a 'toy app', so I learned to handle these via XML.

Over time, I realized I did most of my work on the XML side, and realized it was not as horrific as I thought it would be. So for me personally, it was a case of poor documentation and not seeing a significant savings in coding time.

That being said, there may be some huge advantage/disadvantage that I'm missing, and I'd really like to hear some opinions from folks who have more experience in working with these tools.

like image 582
Bob Palmer Avatar asked Jan 22 '10 12:01

Bob Palmer


2 Answers

Compile-time safety and refactoring (renaming classes, properties) are one of the benefits you get from fluent mappings. Using one language (C# or VB.NET) to write mappings, program code and data access is another benefit.

like image 154
Darin Dimitrov Avatar answered Oct 05 '22 05:10

Darin Dimitrov


  • Compile-time name- and type-safety
  • IntelliSense to show you which fluent methods are available at any point
  • Customizable defaults
  • Automapper
like image 27
yfeldblum Avatar answered Oct 05 '22 06:10

yfeldblum