ORM tools are probably one of the most time-saving tools for a web developer. Nothing is more tedious than building a data access layer, adding caching or coordinating transactions. Well okay, sometimes things like that are really fun, but when you're trying to start a project out from scratch you want to get something up and running ASAP to show to your customers.
In the .NET world there are two powerful ORM tools out there, NHibernate and SubSonic. NHibernate is based on the successful and popular Java EE ORM Hibernate. SubSonic is an entirely new ORM developed in the Ruby on Rails ActiveRecord development model, with some nice .NET 2.0 features like Controllers that you can use with ObjectDataSource controls.
For a recent project I quickly evaluated both software tools, and I'm publishing what I learned here.
Setting up NHibernate:
The NHibernate Object/Relational Mapping is setup using XML files. If you're using the 3.5 Framework you can use a fluent interface instead (i.e. code the mapping in C# instead of XML). I didn't find a tool that generated the XML or interface automatically for you, but there must be one out there.
Changes to the database require changing the mappings, which means digging through XML.
Setting up SubSonic:
SubSonic mappings are generated via an external tool called SubCommander run from the tools menu. Any changes to the database require regenerating these mapped classes. SubCommander connects to your database, reads the Schema and generates O/R classes. The O/R classes are Partial classes in C# so that you can create methods for the classes that won't get overwritten by the tool each time you write it.
Changes to the database require re-running SubCommander (which can be done via the IDE).
The SubSonic team has also come up with some great videos to help you get started.
The big thing that sold me on SubSonic was the new Migrations feature. It uses a Ruby on Rails style migrations tool to help keep your database versioned. It's really excellent for a first generation tool. It's missing a few things, like it's hard to set Unique Keys, but otherwise it is excellent. This is also the first .NET Migrations utility I've found.
Migrations are one of the easiest ways to keep your database versioned, which has always been a problem for me when updating Test and Production databases.
I ended up selecting SubSonic for the following reasons:
- No XML configuration files (running a tool is much easier, IMHO)
- Their excellent video tutorials and directions on their website