8

In the past 2 years since I started writing business applications (before I did either high level front end or very low level systems programming), learned datasets, linq to sql, and now entity framework. The logical thing to look at next seems to be NHibernate.

Reasons I eventually ended up at EF are: (1) it has the best designer support and (2) it is the most supported by Microsoft.

Reasons (these have elements of assumption) I am interested in NHibernate are: (1) it might not get superceded by a totally different thing as quickly as MS churns data access technologies (2) It seems like its either the front running or second to front running tool for what it does and (3) It appears to be stable and tracable back through time quite a bit.

Has anyone published a comparioson of the two? Is one better than the other for certain types of architectures? Or is it just a matter of style and preference?

2 Answers2

6

At this point I think the main (only?) advantages NH has over EF are some very fine-grained fetching strategies. Instead of lazy-loading OR eager-loading everything, NH gives you some very nice intermediate options.

Having said that, I've never needed that level of control over my data access, and so the simplicity of EF has made the choice an easy one.

Just be aware that the EF designer file that's otherwise so nice to work with can become a nightmare in source control; it doesn't merge well, or at all. Make sure you check it out with an explicit lock anytime you need to change stuff.

3

We're doing a project where the architect chose NHibernate over EF. I wish the choice had gone the other way as a publisher-subscriber requirement was present from the beginning.

If you plan on using sync framework, go with EF, as NHibernate can't cope with the updates (to the columns that specify where the data came from, who changed it and is my copy the latest) that go on behind the scenes.

If you need to replicate data from one database to another (and keep primary keys the same), the session.Replicate function is poorly documented and seems to take longer than a straight copy.

Tangurena
  • 13,324