Ayende @ Rahien

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

ayende@ayende.com

+972 52-548-6969

, @ Q c

Posts: 08 | Comments: 17

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:

image

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.


Comments

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.

Craig

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

Fishy

@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

Oren,

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
ef

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).

Jake

@Diego

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.

FUTURE POSTS

  1. Concurrent max value - 12 hours from now
  2. Production postmortem: The case of the memory eater and high load - 3 days from now
  3. Production postmortem: The case of the lying configuration file - 4 days from now
  4. Production postmortem: The industry at large - 5 days from now
  5. The insidious cost of allocations - 6 days from now

And 5 more posts are pending...

There are posts all the way to Sep 10, 2015

RECENT SERIES

  1. Find the bug (5):
    20 Apr 2011 - Why do I get a Null Reference Exception?
  2. Production postmortem (10):
    14 Aug 2015 - The case of the man in the middle
  3. What is new in RavenDB 3.5 (7):
    12 Aug 2015 - Monitoring support
  4. Career planning (6):
    24 Jul 2015 - The immortal choices aren't
View all series

Syndication

Main feed Feed Stats
Comments feed   Comments Feed Stats