Chomping At The Bits

What .NET ORM Should I Use?

I get asked all the time “What ORM should I use?” I typically answer the person with some spaghetti types/talks which of course runs counter to the DRY principle. To help get away from that, I’ll hash out some of my typical responses below. One thing to keep in mind when reading, is that all of the ORMs mentioned below are really good choices. I’m “picking” one per situation as a way of helping someone avoid the paradox of choice.

“Should I hand-roll my DAL?”

No. Unless you just want an academic/code exercise. The libraries I’ll mention in this post are already built, tested, fast and easy to use. If you are serious about building your application, don’t waste time reinventing this wheel.

PetaPoco – PetaPoco is pretty fun regardless of your needs. If you are already pretty invested in T4 then this is for sure a love connection.

“I want POCOs and I might be doing some MongoDB in my app”

Simple.Data – I have personally not used this one yet, but I always hear wonderful things about it.

“My boss says we just have to use something ~Enterprisey~”

Use OrmLite and tell them it is a MS ADO.NET CPT Gen2 Release of EntityFramework with Enhanced Cloud Coverage™ and Synergized Mix-ins™.

While all these ORMs are pretty easy to use, you should always be doing yourself/your app (and of course your DBA) a favor and profile your DAL. I highly recommend ORMProfiler. I think it supports most if not all of the above ORMs, has a low cost, and you get a ton of information from it.