views:

1114

answers:

1

I'm interested in moving some NHibernate configurations/mappings into the code to help with some maintenance issues. Can anyone provide any advice/pros/cons/comparisons of Fluent NHibernate vs. NHibernate.Mapping.Attributes?

I have some experience with Java Hibernate annotations, which I liked, but I'm curious if the NHibernate attributes are comparable, and whether Fluent provides any major upsides/downsides that should be considered.

+11  A: 

I don't think anybody has done any outright comparisons. It falls down to how comfortable you are with decorating your entities with attributes. Fluent NHibernate is aimed at letting you use NHibernate with a completely unpolluted model, while attributes require you to alter your entities; this is a persistence concern leaking into your domain. Whether that's a problem for you is whether you should choose attributes or not.

Fluent NHibernate also throws a few more things to the table than just mappings. There's also the auto mappings which allow you to automatically map your domain. There's the conventions support which allow you to greatly reduce repetition in your design. I won't repeat everything, but you can read more on the Fluent NHibernate wiki.

James Gregory