I'm looking for a .net OR/M that uses the Active Record pattern and allows the developer to define migrations that will update the database scheme in code. I have seen ActiveRecord over at http://www.castleproject.org/activerecord/index.html - but it is poorly documented (with terribly out of date samples) and there is no production ready release available. My target DBMS is MSSQLE 2008; but preferably the generated SQL will be MSSQL 2000 compatible.

I would rather not use nHibernate, as I understand it requires an XML file to maintain the scheme and has no support for migrations. With .net reflection and attributes, a library's use of XML in this situation is unacceptable and doesn't feel very native to the platform's general use.

My main concern is with maintaining the databsae scheme. As this is for a ASP.NET MVC project, being able to keep database scheme's in sync between environments is a must. The fact that I can't find a single OR/M with built in migration support is amazing considering the popularity of .net - as, like I said before, custom attributes and reflection make this very easy to accomplish in code.

Being able to define my entities without an external configuration file (ala ADO.NET Entity Framework) outside of my entity class is also something that I want to avoid. There is no reason why the OR/M can't infer column names by the use of custom attributes on the associated properties.

Anyway, are there any suggestions? What I am asking for is perhaps non-existent; and if so, are there any first hand accounts of using other .net OR/Ms that you can share?


SubSonic provides Migration support, and works quite well.

Reed Copsey
+2  A: 

I would rather not use nHibernate, as I understand it requires an XML file to maintain the scheme

Have you looked into Fluent-NHibernate, it allows you to define your models using a fluent .net API.

Example from site:

public class CatMap : ClassMap<Cat>
  public CatMap()
    Id(x => x.Id);
    Map(x => x.Name)
    Map(x => x.Sex);
    References(x => x.Mate);
    HasMany(x => x.Kittens);

(Fluent-NHibernate also supports auto-mappings, based on convention)

NHibernate also support Schema Creation and Updating. Schema Creation works a treat, I've used this many times before in web-projects and in-memory unit tests. Haven't used the Updating feature yet because I've been using Migrator.NET for a while that handles this.

Brendan Kowitz
Additional link for schema generation : http://stackoverflow.com/questions/1299373/generate-database-schema-from-nhibernate-mapping
Interesting idea. Still not nearly as simple as I would hope.
Mr Rogers