EF6 Beta1 - db.Database.CreateIfNotExists();启用迁移后不再创建数据库

时间:2013-07-24 02:07:18

标签: entity-framework entity-framework-6

db.Database.CreateIfNotExists();不再创建数据库,并在启用迁移后始终返回true。我也没有在发布节点中看到任何关于它的内容。这是虫子吗?

请注意,在nuget控制台中执行“Enable-Migrations”后,AutomaticMigrationsEnabled = true或false都无效。

public void TestMethod1() {
        //using (var db = new Hive.Models.HiveDbContext()) {
        using (var db = new TestDbContext()) {
            var returnValue = db.Database.CreateIfNotExists();

            Console.WriteLine(returnValue);
        }
    }

public class TestDbContext : DbContext {

}

internal sealed class Configuration : DbMigrationsConfiguration<UnitTestProject1.TestDbContext>
{
    public Configuration()
    {
        AutomaticMigrationsEnabled = true;
    }

    protected override void Seed(UnitTestProject1.TestDbContext context)
    {
        //  This method will be called after migrating to the latest version.

        //  You can use the DbSet<T>.AddOrUpdate() helper extension method 
        //  to avoid creating duplicate seed data. E.g.
        //
        //    context.People.AddOrUpdate(
        //      p => p.FullName,
        //      new Person { FullName = "Andrew Peters" },
        //      new Person { FullName = "Brice Lambson" },
        //      new Person { FullName = "Rowan Miller" }
        //    );
        //
    }
}

1 个答案:

答案 0 :(得分:1)

EF团队回答我,这是EF的新变化。请参考这个主题。 https://entityframework.codeplex.com/discussions/450998