Tuesday 2 November 2010

Goodbye Linq to SQL POCO, Hello nHibernate

After a long time trying to get model first poco working with Linq to SQL (using xml mapping files) we have finally given up and have moved over to nHibernate.

Trying to get Linq to SQL working was confusing, error prone and imposed many requirements on how you implemented you domain objects. The worst thing about it was the fragility of the xml mapping. If you got anything wrong the errors you got were not descriptive making debugging a nightmare.

I have to say so far nHibernate has been a breath of fresh air. I had heard it was hard to learn and was over complex but I have found it fantastically straightforward to use. Our domain objects are true POCO and mappings are easily testable. We are using Fluent nHibernate for the mapping and when there is any error in the configuration the error message is descriptive and easy to debug. User base and community is very helpful and knowledgable.

It is true that you have to give up some of the LINQ features, but we are currently using Linq to nHibernate and may revert to Linq to SQL purely for the reporting as this can render from in-memory repositories transparently.

We have created a number of helper functions\patterns to enable using the domain objects as DTOs in our asp.net MVC interface which I will blog about shortly.... happy hibernation everyone..

2 comments:

  1. Its really great to know that you have opted for nHibernate and absolutely you might be feeling relaxed and free from burden of facing errors and its easy to use as well.Congrats.

    ReplyDelete
  2. Thank you for sharing such type of information.there are very help full information for every one.keep sharing this type of information.
    weight loss pills | weight loss products

    ReplyDelete