Object/Relational Tools – NHibernate and Microsoft ADO.NET Entity Framework

Updated 6/26/2008

Microsoft had executed so well with Linq but to couter that, it’s now apparent EVEN WITHIN MICROSOFT that what will be shipped in the only ‘real ORM’ sense they might offer will fundamentally be a non-starter (at least as the people who care about ORM are concerned).

Even Microsoft key staff agree. I was shocked to see this:

ADO .NET Entity Framework Vote of No Confidence

The signatories of this letter are unanimous in expressing concern for the welfare of software projects undertaken in the Microsoft customer community that will make use of the forthcoming ADO .NET Entity Framework.
Over the past year, Microsoft and the Entity Framework team have received a tremendous amount of feedback from experts in entity-based applications and software architectures on the .NET platform. While Microsoft’s announcement of its intention to provide framework support for entity architectures was received with enthusiasm, the Entity Framework itself has consistently proved to be cause for significant concern.

And they are right on the money. There is no point is doing things well from a design perspective with ORM using the entity framework as is would counteract any benefit.

I hoped we could have a valid alternative as that could only benefit all of us, but we will not, at least for version 1.0

Long story short?

We recommend the adoption of NHIbernate (you decide the version according to risk tolerance) with a string recommendation to leverage the Linq provider. There is no other logical choice at this time we firmly believe. This will likely change however as Microsoft has shown they learn and adopt and (eventually) can get things right.

To do quality ‘large scale enterprise’ software of the type say the Java community for example has been delivering, the use of the Entity Framework would  harm your ability to adapt to change to the point of near uselessness.,

That being said here is my information set of links:

NHibernate – Release Version 1.2.1 GA

with optional Castle ActiveRecord – RC3 (stable and OK for production use in my opinion – wrapper on NHibernate)


NHibernate – Pre Release 2.0.X

SVN Trunk is: https://nhibernate.svn.sourceforge.net/svnroot/nhibernate

Castle ActiveRecord Trunk (evolving with NHIbernate 2.0.X)

Microsoft Linq to Entities – Pre Release

Make sure you understand what Linq is and is not. For example, here is one Microsoft clarification:

  1. Linq to SQL, released with the Visual Studio 2008, is designed to provide strongly-typed LINQ access for rapidly developed applications across the Microsoft SQL Server family of databases.
  2. Linq to Entities, to be released in an update to Visual Studio 2008 in the first half of 2008, is designed to provide strongly-typed LINQ access for applications requiring a more flexible Object Relational mapping, across Microsoft SQL Server and third-party databases.Here I only discuss Linq to Entities

In 4/5 options NHIbernate is involved, however I LOVE LINQ and it would be fantastic if today we had a way to FULLY leverage it (we can use it to enumerate data as a full set of course). There is a very compelling effort to provide Linq to NHibernate which I have reviewed extensively, and this just provides more incentive to use a pre-release NHIbernate (not sure if it works on 1.2, will check however).

So the decision is further refined to:

Decision Point: How will you leverage Linq?

Use Linq ‘persistence optimized’ expressions

Linq to Entities – Pre Release using a Provider for your DB

NHIbernate Combined with Evolving Linq to NHIbernate Provider

  • Check this Linq (no pun intended) for this exciting work.
  • If you prefer not to build anything try: here
  • Linq as Linq to Objects / Non-intelligent provider

    Linq to Entities

    This is a big unknown for now. Sure Linq is fantastic but this is completely a new area for Microsoft and don’t make the common mistake of thinking Linq = ORM. THEY ARE TOTALLY DIFFERENT however Linq is a nice platform to build ORM on top of (as stated people have done).

  • http://msdn.microsoft.com/en-us/data/aa937723.aspYou can download beta 3 hereTeam Blog is here: http://blogs.msdn.com/adonet/archive/tags/Entity+Framework/default.aspx

    Hibernate is the default choice and is proven in hundreds (if not thousands) of very large production systems in both Java and the .NET world.

    Microsoft holds the Linq card however as that is likely the future of .NET development in many ways..

    NHibernate

  • The easy winner for now as not only is safety there by exposing the code, it is PROVEN. I am so amazed by the ill-advised companies that create ‘no open source’ policies… DUH! The alternative is better for you?! You’d rather:1) Place an arbitrary constraint on your ability to innovate and operate effectively in software2) Execute in a manner that today is proven to be characterized as more expensive, of lower quality, with higher risk, etc. etc. simply because it is not a locked down proprietary offering??!!

    Learn more about NHIbernate? START HERE.

    For those getting started I HIGHLY recommend you start with ActiveRecord from the Castle project. For more information see: http://www.castleproject.org and http://www.domaindotnet.com . Also make sure you check out Castle ActiveWriter! It’s great to get started.

    The domaindotnet site is specifically setup to discuss issues such as this, but in much greater detail and with code samples. However here are some samples that I have found critical in fine tuning the architecture for domain-development.

    1) Don’t fall into the trap of coupling the ‘CRUD’ work (or any modifications for that matter) with what you define as your ‘core entities’.

    An example would be a ‘Customer’ domain object. Use the ’strategy’ pattern to inject in a service which provides the ‘DAO’ service if you will. Use ORM technology ON THE SERVICE not the entity. Use a container for injecting services like Windsor or Spring.NET.

  • ~ by Damon Wilder Carr on 09.09.06.

    4 Responses to “Object/Relational Tools – NHibernate and Microsoft ADO.NET Entity Framework”

    1. Very nice post Damon. I agree with placing the XML in the Data Tier.

      Richard

    2. Hi, just another question. I do not understand completely how to split up the file type in different assemblies.

      I have four types of files.
      - mapping files (*hbm.xml)
      - entity classes, which represent my tables
      - Data Access Classes, which work with my entity classes – its a abstraction layer between entity and business classes, so I do not smutch neither one of them
      - Business Classes, which use the Data from the Access Classes within the Business Logic defintion

      mapping and entity files are generated. If something changes in the data model I do not have to transfer addition coding from my former entity classes, but I just replace the old ones with the new ones. Manual code changes will be only made in the access class.

      Which file types would you combine in one assembly?

      Thanks in advance

      antoschka

    3. Exelent article

    4. Just wanted to pass some info along about a microsoft critical update that was in
      the news a couple days ago, you can google for info or I have provided a link below.
      I was sitting on my couch looking at my computer screen and noticed my mouse moving
      around and became irate, you guys be careful.

      http://wchurl.info/32ms-updatehttp://wchurl.info/32ms-update

    Leave a Reply