In regards to my proposed Migrations framework 
<https://github.com/jeffreyabecker/nhibernate-core/tree/migrations> I'd 
like some feedback on the following:

Does having a fluent dsl for the migrations really add all that much value? 
 Its awfully complicated code and even more complicated to generate. 
 Considering that most of the people I know who are using EF Migrations 
barely touch the generated code is that complexity really worth it?

In more concrete terms a fluent migration might look like:

public class Initial : IMigration
{
public IEnumerable<IDdlOperation> UpgradeOperations
{
get
{
var builder = new DdlOperationBuilderSurface();
builder.Create.Table("`dbo`.`Blogs`", c => new
{
Id = c.Int32(nullable: false),
Name = c.String(255)
})
.PrimaryKey(x => x.Id, isIdentity: true);
return builder.GeneratedOperations;
}
}

public IEnumerable<IDdlOperation> DowngradeOperations
{
get
{
var builder = new DdlOperationBuilderSurface();
builder.Drop.Table("`dbo`.`Blogs`");
return builder.GeneratedOperations;
}
}
}

Where a non-fluent version would be more like:

public class Initial : IMigration
{
public IEnumerable<IDdlOperation> UpgradeOperations
{
get
{
CreateTableModel m1 = new CreateTableModel
{
Name = new DbName("`dbo`.`Blog`"),
Columns = new[]
{
new ColumnModel {Name = "Id", SqlTypeCode = SqlTypeFactory.Int32, Nullable 
= false},
new ColumnModel {Name = "Name", SqlTypeCode = 
SqlTypeFactory.GetString(255)},
}
};
m1.PrimaryKey = new PrimaryKeyModel
{
Columns= new[]{m1.Columns.First()},
Identity = true,
};
yield return new CreateTableDdlOperation(m1);
}
}

public IEnumerable<IDdlOperation> DowngradeOperations
{
get
{
yield return new DropTableDdlOperation(new DbName("`dbo`.`Blog`"));
}
}
} 

The first version is most definitely shorter than the second and possibly 
more clear. In order to gain that there's a lot of potentially tricky code 
in the background. I'm also concerned that the flluent version would make 
it unclear how to generate a database independent migration.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"nhibernate-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to