实体框架迁移测试迁移文件

时间:2015-10-26 19:40:14

标签: entity-framework unit-testing migration

我正在考虑将EF Migrations用于我们的数据库。我想创建单元测试来验证是否正确创建了迁移。 (Aka CreateTable(" Foobar")被召唤。) 我看到DbMigration类继承自IDbMigrations,CreateTable不是接口的一部分。

有没有办法验证是否使用正确的参数调用了CreateTable(...),PrimaryKey(...)等?

非常感谢

我想测试的例子

public partial class InitialSchema : DbMigration
{
    public override void Up()
    {
        CreateTable(
            "dbo.address_book",
            c => new
                {
                    id = c.Int(nullable: false, identity: true),
                    name = c.String(nullable: false, maxLength: 125, unicode: false),
                    description = c.String(maxLength: 255, unicode: false),
                })
            .PrimaryKey(t => t.id);
    }
}

0 个答案:

没有答案