4

There are plenty of questions on here that ask 'what ORM should I use with x and y' but I didn't see any that specifically asked how to pick one. Related: Why should you use an ORM?, What ORM should I use for a ASP.Net MVC project?, Are there good reasons not to use an ORM? and more.

There are a lot of ORMs out there in the world. I'd like to get an idea of how to compare them. I've heard about things like active record model and domain model among others and I'm not sure what those mean. So what are a good set of criteria I can use to compare one ORM to another?

Our environment, in case you're wondering, is C#, MVC, SQL Server.

Community
  • 1
  • 1
jcollum
  • 43,623
  • 55
  • 191
  • 321
  • 2
    You have to evaluate ORMs relative to your requirements – Eranga Sep 27 '11 at 23:40
  • @eranga: sure, but my requirements might change in the future so it'd be nice to know what sets one ORM apart from another regardless of what db they are talking to – jcollum Sep 28 '11 at 21:35
  • requirements may change but you now have a set of requirements. Choosing an ORM that fits your current requirements is better than worrying about the future. – Eranga Sep 28 '11 at 23:48
  • @Eranga ok, then what do I do after I've come up with a set of ORMs that fit my requirements? Clearly there are a few that will be out because they don't work with my db, server software etc. But how to evaluate the rest? That's what I'm trying to get at. – jcollum Sep 29 '11 at 00:55
  • That is not what you have asked in the OP :) People will be able give you more relevant answers if you give more details. – Eranga Sep 29 '11 at 01:37

1 Answers1

5

(I tried to answer in a non-.NET specific way when possible.)

The most important criteria for choosing an ORM are your business requirements.

I would say another important criteria is your belief in the future sustainability of the ORM. Microsoft has a tendency to change their data access technology every two years or so, so I would say Entity Framework's future is unclear. NHibernate may follow the same path as NUnit - when Microsoft released MSTest, NUnit languished for a while, but now NUnit has momentum again since Microsoft is mostly neglecting MSTest. You have to reach your own conclusion here, right now Microsoft appears to be giving Entity Framework some love, yet as far as I know it still doesn't handle enums very well and I haven't heard when that may change.

Another criteria is whether you have a preference between open source technologies or technologies from Microsoft or commercial third party technologies.

At some point, the features of the ORM will matter. You may need to prototype your scenario with multiple ORMs to determine if the features (and/or performance) of the ORM match your requirements. NHibernate is the most feature rich ORM in the .NET space.

Do you need to support a certain database vendor? Pick an ORM that supports the one you care about. SQL Server is the most widely supported database vendor in the .NET world.

Do you have a preference between code first or database first design? Pick an ORM that supports the one you care about.

Do you have a preference between active record vs. repository vs. something else? Pick an ORM that supports the one you care about.

I answered the question linked below about choosing a .NET ORM partially by providing links to all the times people asked which .NET ORM they should use on StackOverflow. There is a lot of value that can be gained from reading those other answers.

NHibernate, Entity Framework, active records or linq2sql

There is no one right answer nor one correct set of criteria for choosing. Your business requirements are the most important ingredient to consider.

Community
  • 1
  • 1
Michael Maddox
  • 12,331
  • 5
  • 38
  • 40