Some constraints:
- As migrations reflect the database in a certain period of time, C# Expressions can't be used as in case of a class be renamed, old migrations will be changed.
[Migration(201501011618)] | |
public class CreateProduct : AutoReversingMigration | |
{ | |
public override void Up() | |
{ | |
Create.Table("Product") | |
.WithPrimaryKey() // .WithColumn(p => p.Id).AsInt64().NotNullable().PrimaryKey().Identity() | |
.WithName() // .WithColumn("Name").AsString(64).NotNullable() | |
.WithMoney("Price") // .WithColumn("Price").AsDecimal().NotNullable() | |
} | |
} |
public class MigrationConventions : MigrationConventions | |
{ | |
public MigrationConventions() | |
{ | |
// TODO: Convention for versions higher then x | |
ForPrimaryKey(x => x.WithColumn("Id").AsInt64().NotNullable().PrimaryKey().Identity()); | |
ForName(x => x.WithColumn("Name").AsString(64).NotNullable()); | |
// before version 201501011618 were not nullable | |
ForMoney(x => x.WithColumn("Price").AsDecimal().NotNullable()) | |
.Before(201501011618, x.WithColumn("Price").AsDecimal()); | |
} | |
} |