views:

196

answers:

4

Hi all,

We're trying to decide if it's worth using entity framework 4 on a project. To that end, I think a good place to start would be by comparing it to nhibernate, which is mature and proven by years of use to have all the features people need for enterprisey apps, and find out what features nHibernate has that EF4 is missing out on.

So to start, my limited knowledge:

  • Caching: nhib has L2 cache, whereas EF4 has poor caching (?)
  • nHibernate has providers for most DBs, whereas EF needs addons for non-sql db's
  • nHib is faster / more optimised
  • nHib has extension points (eg custom field types)
  • ... what else?

Found some articles:

http://ayende.com/blog/archive/2010/01/05/nhibernate-vs.-entity-framework-4.0.aspx

http://dotnetslackers.com/articles/ado_net/A-Feature-driven-Comparison-of-Entity-Framework-and-NHibernate-Multiple-Databases.aspx

http://dotnetslackers.com/articles/ado_net/A-Feature-driven-Comparison-of-Entity-Framework-and-NHibernate-Multiple-Databases-Part2.aspx

+1  A: 

I'm using Entity framework in a desktop application, and while I'm quite satisfied with it, there is a drawback with using DateTime objects - you can't access the properties, most importantly, the DateTime.Date property.

Also, you can't use Entity Framework foreign objects (that is: objects not in the Entity Framework context, like maping Journal to JournalDto) in your LINQ queries, ie. when mapping - you have to execute the query with ToList() first and do your mapping then.

Concerning the EF tools being buggy - I didn't notice anything concerning that, but I probably just scratched the surface of the framework.

Femaref
Statement 2 isnt correct, you can use Navigational Properties to retrieve "foreign key" objects directly in your queries, OR you can explicity do joins. Plus you can use eager loading (.Include) to explicity load the objects (if you have disabled lazy loading).
RPM1984
That's quite odd about the datetimes! What happens when you try to access the properties? I can't see how a datetime can only 'half' work, given that it's a primitive type.
Chris
RPM: you read the sentence with the wrong intonation. I hope my edit clarifies it. I didn't mean foreign key relationships.
Femaref
@Fermaref - yep, your clarification helps. My bad.
RPM1984
+3  A: 

NHibernate supports other databases apart from SQL Server, e.g. if you are using Oracle. The Entity Framework itself is designed to support muliple provider but the only built in provider you get is for SQL Server. Oracle hasn't released any provider yet and there are commercial or patchy free providers for other datbases. So if supporting multiple DB is in scope then NHibernate is ahead of EF 4 at this time.

Pratik
Thanks for that. I'll add it to the list. Not an issue for us however, as we only use sql servers.
Chris
+2  A: 

Although I don't have much experience with EF, one of the biggest selling points of NHibernate is its extensibility points. User Types and Event Listeners are great examples of just how customizable all aspects of the NHibernate experience are.

DanP
Cheers, thats good to know
Chris
+2  A: 

I tried entity framework when it first came out and I found the configuration to be overly complicated when doing anything that is not standard (with any real life application, things aren't as perfect as the examples). With nhibernate, complexities were quite easily addressed in very readable mapping files. Entity framework mapping files were not nearly as readable.

i8abug
You know, that's been exactly my experience. If you step out of their narrow boundaries of expected ways to do things, you really get hit with walls of complication.
Chris