tags:

views:

302

answers:

4

(This must be a FAQ, so I expect it to be closed as duplicate, however I can not find a question that contains a good overview of the issues etc.)

What should someone consider when choosing an ORM for a .net system?

How are the above addressed by the ORM that are in common usage for .net systems.

(Witch stack overflow question should I link to in an answers when I says “consider using a ORM” for a .net question)

A: 

I am not a .net developer, but you should check out nHibernate. It is the .net version of the state of the art ORM for Java. I am sure it is a great solution for .net too, as ist makes mapping objects quite easy, but is still powerfull enough to map objects to nearly any kind of sql schema.

Mobbit
+2  A: 

ORM Battle
A entire website dedicated to analysing and comparing various .NET ORM (Object Relational Mapping) products!

Bear in mind, though, that even the ORMBattle website only compares about 7 or 8 ORM's (although the ones it does compare, it seems to do so fairly thoroughly but see disclaimer below).

According to the SharpToolBox website, there are about 40 ORM's available! The list of ORM products, and their descriptions on the SharpToolBox website should give you a good start. See here: SharpToolBox Search Results for Object-Relational Mapping

Considering that pretty much every developer, and every application's data access needs can vary, finding a complete comparison between all of them will be difficult. This is probably the reason that over 40 different ORM products exist since there is no "one-size-fits-all" in the world of ORM.

Also, please bear in mind that any comparisons between ORM products may well be "flawed" since you can't always be sure that the various functionality of different ORM products is designed for the exact same purposes. A comment by AJ on this answer links to a blog post by Ayende Rahien who describes exactly this phenomenon when ORMBattle compared NHibernate to other ORMs.

I think the best approach is to look at the benchmarks, and read the descriptions of each ORM, but don't take those things literally, but rather interpret those figures based upon what your own application should be doing. For example, if your application primarily reads and writes database records one at a time, you'll probably use a completely different ORM product than an application that needs to process database records in batches.

CraigTP
The usefulness of the analysis done by ORM Battle is highly contested... a good read: http://ayende.com/Blog/archive/2009/08/15/benchmarks-are-useless-yes-again.aspx
AJ
@AJ - Interesting article. I do agree that benchmarks (of anything) can be misleading. This is why each person looking for an ORM tool should do their own research due to everyone (and their needs) being different. Benchmarks can often be like statistics, and we know how useful they can be! ;) (http://www.quotegarden.com/statistics.html)
CraigTP
That's why there is big FAQ section :) See http://ormbattle.net/index.php/faqs.html
Alex Yakunin
I can add why there are JUST 8 products now: few commercial vendors simply asked us to remove their results. I think that's not really funny at all - see e.g. http://ormbattle.net/index.php/blog/93-great-quote-from-todays-e-mail.html
Alex Yakunin
We'd add other tools, if they support LINQ, but it seems there are no more such candidates. And finally, we invite everyone (with or without LINQ support) - test suite is fully open source.
Alex Yakunin
+3  A: 

This is the main question/answer I have been pointing people at in regards to choosing a .NET ORM:

http://stackoverflow.com/questions/1377236/nhibernate-entity-framework-active-records-or-linq2sql/

I put a bunch of the "duplicate" type questions in my answer on that one. So there is plenty of reading you can do from a variety of different perspectives.

I'll also try to answer your specific questions:

What should someone consider when choosing an ORM for a .net system?

  • You want to make sure it works with your database. If your database design was state of the art 15 years ago, many of the smaller and/or less mature ORMs won't work with your lack of keys, weird relationships, etc.

  • You want to make sure it works with your database vendor. SQL Server support is pretty much always available, but other databases may or may not be supported by various ORMs (MYSQL seems to be the second most commonly supported database).

  • If you want to generate your database based on your .NET classes, you need to make sure your ORM supports that.

  • If you want performance, I guess you stay away from the bad performing ones, but those would never make a top 5 list, so as long as you go with an ORM that has some mainstream street cred, you are probably fine here.

  • You need to make sure it has features you need supported: http://ayende.com/Blog/archive/2006/05/12/25ReasonsNotToWriteYourOwnObjectRelationalMapper.aspx

  • Consider vendor lock-in and how easily you may or may not be able to escape it (for both the database vendor and the ORM vendor).

  • Consider how much you want to spend.

  • Consider what you want for code generation.

  • Consider what you want for unit test support.

  • Consider how much time you want to spend researching the various options.

  • Consider the community that exists around the ORM.

There are plenty of things to keep in mind. I'm sure I could think of more. In the end, a lot of it is situational and you need to make your own decision what is best for you and your project.

How are the above addressed by the ORM that are in common usage for .net systems.

The only .NET ORM that I am aware of that meets pretty much all needs a .NET project could have (minus the more obscure database vendors) is NHibernate. It has been tested with a lot of "legacy" databases in a lot of different scenarios.

Michael Maddox
+1 for NHibernate
Travis Heseman
A: 

Take a look a Worm. It is thread safe and supports caching, so it very suit for high performance solutions.

Alexey Shirshov
Does it support LINQ?
Alex Yakunin