Ayende @ Rahien

My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:


+972 52-548-6969

, @ Q c

Posts: 6,125 | Comments: 45,488

filter by tags archive

NHibernate vs. Entity Framework: Usage

time to read 1 min | 189 words

This is in a response to a question on twitter:


In general, for applications, I would always use NHibernate. Mostly because I am able to do so much more with it.

For one off utilities and such, where I just need to get the data and I don’t really care how, I would generally just use the EF wizard to generate a model and do something with it. Mostly, it is so I can get the code gen stuff ASAP and have the data working.

For example, the routine to import the data from the Subtext database to the RacconBlog database is using Entity Framework. Mostly because it is easier and it is a one time thing.

I guess that if I was running any of the tools for generating NHibernate model from the database, I would be using it, but honestly, it just doesn’t really matter at that point. I just don’t care for those sort of tools.


Marc Gravell

Unrelated to this post... your "Archive" (right hand bar) seems to be sorting by month number as text, hence Oct/Nov/Dec come between Jan and Feb

Ayende Rahien

Marc, Yes, I know, we are doing some work on RacconBlog now, will be fixed soon

Matthieu MEZIL

Thanks for this answer.

"Mostly because I am able to do so much more with it." Do you think about your NHibernate knowledge vs your EF knowledge or do you think about some NHibernate features not supported by EF? If you think about features what are the top ones you think about?

Ayende Rahien

Mathieu, Because EF is really limited in many of its capabilities.

Xing Yang

Indeed NHibernate has more features and extension points, however sometimes you need to dive into the source code to find out the meaning of an interface method.

Darren Cauthon

I use EF when I'm in the mood to poke out my right eye.

I use NHibernate when I'm in the mood to poke out my left eye.

José F. Romaniello

I wrote a detailed review of EF 4.1 CodeFirst RC vs NHibernate when this version came out. http://joseoncode.com/2011/03/30/entityframework-4-1-rc-code-first-review/

Basically, I won't use EF because is very limited, and for simple things I won't use NHibernate either just ado.net (maybe dapper because it has some nice extension methods).

Jarle Friestad

With nuget there is no execuse for not using NHibernate either. Add package => nhibernate => done

Matthew Shapiro

My main production app was written with EF code-first. At first I loved it, but the more I use it the more "gotchas" I find. I don't really want to go through the whole thing and waste time replacing it with NHibernate (mostly since I used EF because there was better docs for learning EF4 than NH) but I definitely would use NH over EF for any new projects.


Most people who I found prefer EF of NH basically do so because Linq support is 'better'.


@jose thanks for the review I tried the new EF CodeFirst and after all it is'nt that bad if you want to quickly achieve some simple basic things. For complex projects there is no other solution then NH at the moment and i don't know if the better LINQ support in EF is a real argument against NH since there are a lot of other ways for querying data. Documentation is always an issue and the reference at nhforge is not complete and needs a rework. For instance there is no word about the new ConfORM feature and how to use it. The other issue is support. Jose wrotes: "The experts of nhibernate will answer your question in minutes." In the last couple of months it is really hard to get an answer. I asked some questions with unit tests etc. but without any success. Fabio answered a lot of questions in the past, but since he moved back from the project it is really quite in the forum. But in the end there is alyways ligth and shade :-)

Santos Ray Victorero, II


Did you marry someone from Microsoft? :-)

I just finished a couple of Windows Phone projectsI & I missed NHibernate a lot since had to use Linq to Sql the only choice for Sql CE for WP7.

I kind of agree with Jose; EF is very limited. I will not use that thing for anything serious at all.


EF is just good enough.

Diego Mijelshon

Here's my comparison, which I did when I started with EF 4.1: http://stackoverflow.com/questions/5101974/net-orm-comparison/5105917#5105917

Now I would add that convention-based mappers for NHibernate (ConfORM, Fluent) are much more mature and flexible.

EF's ONLY selling point is a more complete LINQ provider. Which, BTW, is not so great when you look at some of the horrible SQL it generates. Not to mention you can't pass entities to it (you need to pass the Id).



You actually missed Entity Frameworks biggest selling point:

Its was made and is publicly endorsed by Microsoft.

Comment preview

Comments have been closed on this topic.


  1. The design of RavenDB 4.0: Physically segregating collections - 14 hours from now
  2. RavenDB 3.5 Whirlwind tour: I need to be free to explore my data - about one day from now
  3. RavenDB 3.5 whirl wind tour: I'll have the 3+1 goodies to go, please - 5 days from now
  4. The design of RavenDB 4.0: Voron has a one track mind - 6 days from now
  5. RavenDB 3.5 whirl wind tour: Digging deep into the internals - 7 days from now

And 12 more posts are pending...

There are posts all the way to May 30, 2016


  1. The design of RavenDB 4.0 (14):
    03 May 2016 - Making Lucene reliable
  2. RavenDB 3.5 whirl wind tour (14):
    04 May 2016 - I’ll find who is taking my I/O bandwidth and they SHALL pay
  3. Tasks for the new comer (2):
    15 Apr 2016 - Quartz.NET with RavenDB
  4. Code through the looking glass (5):
    18 Mar 2016 - And a linear search to rule them
  5. Find the bug (8):
    29 Feb 2016 - When you can't rely on your own identity
View all series


Main feed Feed Stats
Comments feed   Comments Feed Stats