views:

4477

answers:

11

There are many ORM solutions out there, so in your experiences what seems to be the best choice?

NHibernate or Subsonic, Genome,DLinq, LLBLGen - there seems to be a plethora of options, so pros and cons please people.

A: 

I had considered that but there appears to be some "LINQ is dead" stuff creeping through the dev community

http://codebetter.com/blogs/david.hayden/archive/2008/10/31/linq-to-sql-is-dead-read-between-the-lines.aspx

Paul
It is Linq2Sql that some people claim will die. I personaly think Microsoft only made it because they couldn't get Linq2ENtities in the vs2008 release.Linq2Sql migth not get new features, but it won't be that hard to migrate to Linq2Entities.
AndreasN
+15  A: 

I'd recomend NHibernate and anti-recomend Entity Framework.

Entity Framework is all driven by the combined edmx designer. Moving an Entity in the diagram causes the code behind to be regenerated, making it very hard to customize. If customisation is required, you have to manually split the files into 4.

Number of files needed to change an entity: NHibernate: 2 Entity Framework: 4

In NHibernate these are two different files per entity, in Entity Framework it’s the same 4 files per database which can get big and unweildly.

With NHibernate, an additional config file is needed, but this only needs to exist once. (Or once per database in a multidatabase environment.)

If you use tools such as CodeAnalysis or StyleCop, the auto generated files fail these and can't be fixed due to the regeneration issue mentioned above. The only ways to put a "generated code" attribute on them is either create a partial stub with the attribute on them or use something to inject it at build time. Niether of which is very nice.

Even with the GUI, do something like adding a new entity with a relationship to an existing one is fiddly, whereas in NHibernate its a small xml fragement.

NHibernate has the advantage of being extensible by things like Linq2Nhibernate, Castle Active Record (if working with the XML files doesn't appeal this sits on top and is done entirly by attributes.)

If you work in a non-exclusive checkout system, then the prospect of having to merge the EDMX, or its split versions is a nightmare, where as in NHibernate there is a file per class (or entity) making it a lot more managable.

LinqToEntities is missing Contains support that Linq2Sql has which has caused me no end of headaches.

Just my opinion. Hope that helps.

DeletedAccount
Having worked with NHibernate I fully +1 this. It's easy to use and preforms extremely well. The Criteria API allows for fully type-safe query definitions and the option to use HQL for more complex cases adds even more value.
Ruben Steins
@Ruben - can you partially +1 something? :) Seriously though, I agree
Luke Schafer
+1  A: 

If SQL Server is your database, then LINQ to SQL, if it's a different RDBMS (MySQL, PostgreSQL..) then SubSonic.

If you use one of the MySQL, PostgreSQL, Oracle or SQLite and care about commercial packages then dotConnect from Devart (formely CoreLabs) should be good. We missed LINQ to MySQL by a few months in my newest project, so we went for SubSonic, but if I was starting right now I would be looking at LINQ to MySQL definitely.

Pawel Krakowiak
A: 

I don't recommend Subsonic, it's being pain in my arse in my first subsonic project, I hated it at the end. I spend large amount of time to fix Subsonic bugs instead of developing stuff (especially support for MSSQL 2000 was really weak). They actively keep fixing bugs and massively introducing new features. This is good and bad. But this is generally bad if you are going to use it in a big project.

I used Raptier, it's really simplistic and good although it's a dead project now, so not a good choice for a new project.

dr. evil
+16  A: 

Largely depends on your requirements and nfrs like performance. Of course, you might want to evaluate all the already mentioned options like nHibernate, Subsonic, Entity Framework, LINQ to SQL etc

Also, remember that there are some other, not so popular ORMs or ORM like stuff out there as well. Here is a list I pulled together some time back. Do some POCs and performance testing and decide based on your requirements.

This list is not in any specific order.

  1. Neo - Neo is a framework for .NET developers who want to write enterprise applications with an object-based domain model. It is well suited for domain-driven design and agile development. Pretty good for small apps See http://neo.codehaus.org/

  2. nHibernate - NHibernate is a .NET based object persistence library for relational databases. It is a widely used OR persistant tool these days. It is inspired by Java hibernate. See http://wiki.nhibernate.org/display/NH/Home

  3. MyGeneration DoodAds - DoodAds is an elegant .NET architecture available in C# and VB.NET and capable of supporting any .NET managed data provider. Currently dOOdads are available for Microsoft SQL, Oracle, Firebird, Access, PostgreSQL, VistaDB, SQLite, and MySQL . You can use MyGeneration Code Generator to generate DAL classes easily for DoodAds. See http://www.mygenerationsoftware.com/ . I used this some time back for some quick implementations.

  4. EasyObjects.NET - EasyObjects.NET is an object relational mapper (ORM) architecture based on a combination of the popular MyGeneration dOOdads architecture and the Microsoft Enterprise Library. See http://easyobjects.tigris.org/

  5. DataBlock - DataBlock is a Object Relational Mapping and persistence framework for .NET 2.0. - See http://www.voidsoft.ro/DataBlock/index.html

  6. AdapDev.NET - Adapdev.NET is a robust enterprise framework that supplements the MS.NET framework. It's the foundation of Codus (OR Code generator) and Zanebug (A unit testing framework) providing the underlying code generation and unit testing engines. See http://www.adapdev.com/

  7. Gentle.NET - Gentle.NET is an RDBMS independent object persistence framework. It features automatic SQL generation and object construction, an SQL factory for creating custom queries, DataView construction helpers, excellent performance and reasonably complete docs. See http://www.mertner.com/confluence/display/Gentle/Home

  8. IBatis.NET - The iBATIS Data Mapper framework makes it easier to use a database with Java and .NET applications. iBATIS couples objects with stored procedures or SQL statements using a XML descriptor. Simple and elegant..See http://ibatis.apache.org/

amazedsaint
MyGeneration authors created (and still work on) a commercial framework named EntitySpaces (www.entityspaces.net), which integrates with the free MyGeneration tools.
Pawel Krakowiak
Do you have an opinion on Entity Framework, just out of interest?
DeletedAccount
Sadly, Gentle.NET appears to be dead.
Kramii
While Castle's active record is based on nhibernate, it needs to be listed. Also some of these are really to immature, and will just confuse a novice.
Mark Rogers
Gentle.NET's still available at http://sourceforge.net/projects/gopf/ - it's quite nice, but AFAIK the author is no longer actively evolving it. iBATIS looked like it would handle legacy databases quite well. Tools such as CodeSmith can be quite handy to generate business objects for some of these O/RMs.
TrueWill
+3  A: 

in my opinion Linq to SQL is only useful for small projects, because there a some important features (for me) missing, like n:m support.

Martin Moser
+6  A: 

I really like LLBLGEN Pro. Top bit of kit. really nice piece of software

solrev
+3  A: 

I've been writing my own for years (since my vb5 days). Usually design DB first then generate classes based on templates to use with a general-purpose DAL (the latest incarnation of which I took about half an hour to write. SQL Server only though I have to say..).

In a modern environment where there are so many products available maybe that it's probably not a supportable POV - advantages are that you can get exactly (and only) what you need, and you have control over bugfixes/new features.

If you do go down this road, I'd recommend quite a lot of thought into exactly how you split the responsibilites (smart object/dumb object, when you load linked/child objects etc.) and how you handle security/permissioning issues... I'd recommend having the db do as much of the heavy lifting as possible - keeps your code cleaner. I'd steer clear of MS's strongly-typed datasets (incomplete, lead to repetitive code compared to a good library for use with plain ones and throw exceptions if you try to access a field whose value is null!!!). I also use composition a lot, but that may just be my VB background. Or the fact that I am keen on unit testing...

IMHO, ORMs that only generate code for individual tables, or SELECT *, or even SelectByPrimaryKey, are of limited use and can lead people to produce ugly/inefficient code. You need to be able to back them with sophisticated (stored) procedures to allow full, performant, selection and correctly cascading/checked deletion. A selection criterion there for an ORM.

I use ORMs because they make clearer code and a better, more robust and adpaptable architechture. I sometimes feel that some developers use them cos they are scared of SQL. I've always rather enjoyed the database side of things, and have solid design and SQL/T-SQL skills (the PL-SQL is a little more rusty these days...).

You'll get a lot more out of whatever ORM you pick if you understand and use the power of your database engine.

but maybe I am just a dinosaur...

kpollock
+3  A: 

Here are two additional ORM products which you might consider when chosing a product for your solution:

  • Mindscape Lightspeed:
    "Enterprise-grade ORM that does the data access plumbing in desktop and web applications. Supports both forward and reverse mapping".
  • Telerik OpenAccess ORM:
    "High performance .NET domain modeling and O/R mapping framework".

(Description of the products taken from their websites).

Since I have not yet used these products for anything productive, I can not give any recommendation. For both products, there exists a free version that can be used to evaluate the product.

M4N
For the record, the latest release of OpenAccess ORM will support full "round-trip mapping." That is, you can reverse or forward map between the DB and classes at any time (using visual designer in VS). Pretty unique advantage among ORMs. [FULL DISCLOSURE in my profile.]
Todd
+6  A: 

Hi,

I would also consider choosing an ORM on is support and muturity.

Linq2Sql,

  • looks like MS have dropped actively adding to this project (now only on resquest)
  • Low level ORM (Single level inheritance, all inherited types in a single table)

Entity Framework,

  • New, which would suggest that all the querks have not been found. (vote of no confidence).
  • Heavy wieght, supports more levels of inheritance
  • GUI for creation of mappings

Hibernate

Neo

  • still does not support 2.0 (generics), looks like the project is has lost active support (last update in 2006)

AdapDev.NET

  • although I like the projects, Sean there is some awesome work there. It seems the site has had no updates for a while?. which would suggest the support for these products to be limited. (please correct me if im wrong.)

you may have notice I mentioned the level of inheritance. please look at Matin Folwer's EAA

HTH

Bones

dbones
+1  A: 

EntitySpaces - http://www.entityspaces.net/Portal/Default.aspx

From Mobile Devices to large scale enterprise solutions in need of serious transaction support, EntitySpaces can meet your needs. Whether you’re writing an ASP.NET application with Medium Trust requirements, a Mono application, or a Windows.Forms application, the EntitySpaces architecture is there for you. EntitySpaces is provider independent, which means that you can run the same binary code against any of the supported databases. EntitySpaces is available in both C# and VB.NET. EntitySpaces uses no reflection, no XML files, and sports a tiny foot print of less than 200k. Pound for pound, EntitySpaces is one tough, dependable .NET architecture.

quimbo