ORM Choices

These days in .Net ORM’s appear to be close to religion. With heavy hitters like Entity Framework and the micro ORM’s like Dapper, there just isn’t much of a middle ground as far as speed and ease or even features. In my search for an ORM that met being light weight and fast while providing full LINQ capabilities I stumbled upon Linq2DB.

In my opinion it’s a happy medium between the heavy weight of Entity Framework or NHibernate while not forcing me to actually write sql.

It provides a easy to use bulk insert option as well as supporting many of the well known RMDB’s ( Sql Server, Oracle, Postgres, MySql etc ). It’s quick, not quite dapper quick but thats the trade off i’m ok with making for it generating the sql for me. It also comes with a nice set of T4 templates for reverse engineering your current data base into poco’s ready for use ( also very fast, last i used it on a 1200 or so table database this took 1-2 min )

It does not provide any version tracking or caching like other ORM’s do, if this is a feature you need then you’re likely already using EF.

This is not a post about hating on EF, so before going further let me say I Actually like Entity Framework for a couple reasons, most namely the Include extension method for eager loading children. Linq2db does provide this but it’s not as flexible, I haven’t yet been able to figure out how to load multiple children if i needed to. It’s also easier to run into issues with the LoadWith method. If used within a foreach (without .ToList()) this will end up with the age old n+1 queries to the database. It also has the largest user base that I’ve been able to find so getting help is very simple. Hopefully good things come when EF 7 is finally RTM

Other things to know about ORM Choice, If you plan on using Identity 2.0 with any ORM that isnt Entity Framework you’re in for a treat because you’ll need to write up the interaction to the database. I have however provided a good starting point for you if required.
Linq2db Identity 2.0 implementation

Leave a comment