none
EF6 Code first with existing database. disable migration RRS feed

  • Question

  • I am using EF6.  code first with existing database.

    I have set

            static MainContext()
            {
                Database.SetInitializer<MainContext>(null);
            }

    and

            public Configuration()
            {
                AutomaticMigrationsEnabled = false;
            }

    But there are several table not found errors. the following are the tables not found .

    __MigrationHistory

    EdmMetadata

    How can i fix this problem?

    Monday, November 2, 2015 3:44 AM

Answers

  • Hi Andrew, 

    According to  this case , I create the test project. I can find all tables in my database

    if it generate from code first model. If I using the database first mode to generate

    database, it will not generate the __MigrationHistory table. But other tables are still exists .

    My code and table as shown blow:

    static CodeFirstEFBlogContextContext()
            {
                Database.SetInitializer<CodeFirstEFBlogContextContext>(null);
            }
    =============================================================
    public Configuration()
            {
                AutomaticMigrationsEnabled = false;
            }
    

    My Tables:

    Best Regards,

    Vince Li

    Wednesday, November 4, 2015 9:28 AM