Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have created an asp.net mvc Project that is using the Entity Framework Code first. Migrations are enabled. When I deploy Project on IIS, the migrations error that occurs is:

Migrations is enabled for context 'MyContext' but the database does not exist or contains no mapped tables. Use Migrations to create the database and its tables, for example by running the 'Update-Database' command from the Package Manager Console.**

share|improve this question

2 Answers 2

I had the same problem recently, I solved it like this:

  1. In the constructor of your Configuration class turn off the migration:

public Configuration() { AutomaticMigrationsEnabled = false; }

  1. Drop the table __MigrationHistoryfrom your production database.
share|improve this answer

Try using this putting in your global.asax

Database.SetInitializer(new MigrateDatabaseToLatestVersion<MyContext, Configuration>());
        using (MyContext temp = new MyContext())
        {
            temp.Database.Initialize(true);
        }
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.