LINQ to Entities vs. NHibernate

by Dave on March 17, 2007

in Old Blog

At the MVP Summit I got a chance to participate in a great, vehement, passionate, and deep conversation about the forthcoming ADO.NET Entity Framework with the Microsoft team responsible and some of the main leaders of the Agile .NET community.

A recent post from Jeremy Miller:

I am putting a post together on what we saw from Linq to Entities this week, but let’s just say that I thought the only compelling technical advantage it had over NHibernate is Linq queries. One of the smart aleck comments somebody made was that Ayende would probably add a Linq front-end to NHibernate over a long weekend.

I can’t agree on his the only “compelling technical advantage” comment. Perhaps true from the standpoint of what ships with Orcas release of VS, but as a long term vision I think we need to seriously consider this as a positive step.

What’s coming is not an ORM, therefore there is no comparing the two.

In the traditional ORM (NHibernate) world you have two models: domain objects and database. The mapping is there to, well, map the two worlds: to bring them together. It’s there to solve the (generally overhyped) impendence mismatch.

That said, EDM (Entity Data Model) is a logical representation of a data model. The framework will permit various “services” to be attached to this model such as domain objects/models containing behavior (which is what we want to test and test-drive after all) replete with LINQ queries, reports, mock and test data generation, entity aggregation type service endpoints, etc.

With EDM and its associated platform, OR mapping is merely one facility (of many) possible. It’s a rather ambitious and appealing vision. You can read more about it here and here

Jeremy goes on to say that Ayende is working on a LINQ to NHibernate. I’m a big proponent of NHibernate and I will most likely stick with it until the LINQ to Entities framework fleshes out a bit (I don’t see myself as an early adopter on Entity Framework at this point).

It’ll be awesome to have a strongly typed Query Object, but I think I’ve mentioned this before. Not 100% sure if I’ll be ready to give up externally mapped queries, but we shall see after some play and consideration.

  • So what really is the big difference between ORM and LINQ that you claim is so great? I'm a huge supporter of LINQ because i like the idea of deferred execution, the functional programming style of queries in code, and the infinite possibilities of LINQ to . I hope some of the cool tools that LINQ to SQL has needs expanded to the other data sources (Ole and Odbc off the top of my head) but what about LINQ to soap services?

    Anyhow, keep up the great discussions... it helps other people 'get it' and hopefully increases the chance of buy in when something like this would be somethign that helps the bottom line.
  • Gaurang Shah
    Let me try to answer your question with some simple words. LINQ is basically something you write querries for in your code. Now can u imagine a tool or something which will let you write your application without any querries? That is exactly what ORMs do. Entity framework or NHibernate or Hibernate(for Java) are all ORMs. ORM lets you relate your object model to the database model. So when you want to retrieve some data from table A for any corresponding object in your object model, all you say is get(a) Vs. writing LINQ in your code. ( note that this is not correct syntax, I am trying to explain you the concept only). I hope this helped.
  • AM
    Hi there: After reading your post is not really clear to me whats the advantage of the entity framework, am i wrong to say that the entity framework basically means you have to write everything yourself? why go to all that trouble? or am I been overly simplistic? I ve seen a few samples in msdn and TBH i m not impressed. I m perhaps a bit biased towards NH because i really like it and I think it makes you a better dev however I just cant see how this is any good.
    This is the first comparision or comment I find from someone that actually uses NH and that its positive(?) i would really like to undestand why
    Thanks
    A
  • Dave
    Yeah! I think it's an incredible vision. One we've had to work toward by writing our own software. I'd much rather you guys write it! :)

    There was a genuine feeling of "trying to understand" despite lots of passion coming from all angles. What made the event cool and a happening (for me) was that, while there was lots of talking going on, there was also an appropriate measure of listening. I think that's the rare and special thing, especially when there's emotional investments in a particular technology one is working with or working on (as the case may be).
  • Brian Dawson [MSFT]
    David,

    I was on the MS side of things during the discussions, and let me just tell you, the discussion was great. When we're building software and you get a chance run into a group of people who get the vision, and also get some of the hurdles we have to jump; you really listen to the feedback. Thanks! Don't let up.

    -Brian
blog comments powered by Disqus

Previous post:

Next post: