【问题标题】:EF6 Beta1 - db.Database.CreateIfNotExists(); doesn't create the database anymore after enabling the migrationEF6 Beta1 - db.Database.CreateIfNotExists();启用迁移后不再创建数据库
【发布时间】:2013-07-24 02:07:17
【问题描述】:

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

请注意,在我在 nuget 控制台中执行“启用迁移”后, 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" }
        //    );
        //
    }
}

【问题讨论】:

    标签: entity-framework entity-framework-6


    【解决方案1】:

    EF 团队回复我说这是 EF 的新变化。请参考这个线程。 https://entityframework.codeplex.com/discussions/450998

    【讨论】:

    • 现在链接失效了,可能是移到github了?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-01-17
    • 1970-01-01
    • 1970-01-01
    • 2021-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多