Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EF6 Beta1 - db.Database.CreateIfNotExists(); doesn't create the database anymore after enabling the migration

db.Database.CreateIfNotExists(); doesn't create the database anymore and always return true after enabling the migration. I don't see anything mentioned about it in release node as well. Is it the bug?

Note that both AutomaticMigrationsEnabled = true or false are not working after I do "Enable-Migrations" in nuget console.

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" }
        //    );
        //
    }
}
like image 824
Michael Sync Avatar asked Jul 24 '13 02:07

Michael Sync


1 Answers

EF team responded me that it's a new changes in EF. Please refer to this thread. https://entityframework.codeplex.com/discussions/450998

like image 93
Michael Sync Avatar answered Oct 13 '22 00:10

Michael Sync