views:

5140

answers:

6

A lot has been talked about Entity Framework first version on the web (also on stackoverflow) and it is clear that it was not a good choice when we already have better alternative like NHibernate. But I can't find a good comparison of Entity Framework 4 and NHibernate. We can say that today NHibernate is the leader among all .NET ORMs, but can we expect Entity Framework 4 to displace NHibernate from this position. I think if Microsoft has really injected very good features in EF4 it can give good competition to NHibernate as it has Visual Studio integration, easier to work with and preference is always given to MS products in most shops.

+5  A: 

I think the fact that EF 4 will have the ability to use POCO and deferred lazy loading will be very big. I could definitely see it gaining traction with the new release.

YeahStu
Don't forget LINQ support. NHibernate still ain't good at it.
Arnis L.
@Arnis, can you provide any links to back that opinion up?
Michael Maddox
@Michael this is apparent when you look through Ayande's blog posts on the subject. LINQ to NH is based on the criteria API at present. The criteria API doesn't allow some of the more complex query functions that HQL can. The next release of LINQ to NH will use HQL instead of criteria API.
zowens
+8  A: 

Here's the thing. NHibernate and Entity Framework are really for two different audiences, in my mind. NHibernate would be my choice in building a system with complex mappings, formulas, and constraints (basically anything enterprise). If I wanted to hit-the-ground running with simple data access, I would use Entity Framework or LINQ-to-SQL. NHibernate doesn't have a clear "drag-and-drop" experience quite like EF. Both have their strengths and drawbacks. Comparing them apples-to-apples, frankly, gets you nowhere.

zowens
Have you tried ActiveWriter? Entity Framework is absolutely targeted at the enterprise space. I disagree with most of what you said.
Michael Maddox
Disagree all you want but the fact that NHibernate has been around longer is something enterprises DO NOT overlook.
zowens
What is ActiveWriter, I have never heard about this?
Deependra Solanky
-1 This is not a good comparison of NHibernate vs. Entity Framework. Comparing the two by lumping EF in with LINQ to SQL just b/c it has drag-and-drop is disingenuous at best. As far as complexity, what exactly is it that NHibernate can do that EF 4 can't?
Kevin Babcock
Second Level Caching, their queries are HIGHLY optimized, NH forces you to use the UnitOfWork pattern, plus mappings aren't jammed into one file. My opinion (from experience) is that NHibernate is more performant. Disagree with me on that, but I did say that was my opinion. My point in my answer is STILL valid, they BOTH have their strengths and weaknesses. No one can deny that.
zowens
-1 Your answer is mostly a blanket statement saying NH is better. More detail is needed.
MakerOfThings7
+5  A: 

There's a good discussion over at Ayende's blog: http://ayende.com/Blog/archive/2009/10/14/what-is-up-with-the-entity-framework-vnext.aspx

Martin R-L
There's a good 'biased' discussion. With this sort of question, you have to take the source of your information into account.
mattmc3
+15  A: 

EF4 has an out-the-box answer with regard to n-tier development, in "self-tracking entities". Nobody has released comparable code for NHib.

NHib has many features that have not been mentioned as being part of EF4. These include the second-level cache integration. It also has greater flexibility in inheritance mapping, better integration with stored procs / database functions / custom SQL / triggers, support for formula properties and so on. IMO it's basically just more mature as an ORM.

John Rayner
+1 You're right. NH is just mature. EF will catch up by the end of the year. Version 4.0 has already made a dramatic entrance. Give it some time and it'll be bullet-proof by mid 2011.
Sergey
+1  A: 

My 2 cents: we use ef on our desktop client for some cahing etc - no hi loads. An NHib on server side - utilizing Stateless sessions, hilo id generation and batches. Is is quite fast in inserting 3k+messages in db per second. Also it is very flexible and supports lots of dbs, wich is crucial for our product.

Alexey Anufriyev
+4  A: 

If you think you might ever want to run your code on Mono, NHibernate is probably a better choice no matter what the feature checklists say...

Joel Mueller