Solution:

Are you moving changes from Development Environment to staging and you are getting above error, well there is a very quick and simple solution to the problem.

Just got to database and delete this table, and it will solve the issue, given that you already have moved the changes to the required tables etc using SQL compare or any other tool.

_MigrationsHistory

Considerations and Other Solutions:

There is an other approach to automatically move the changes to database by using below code in configuration.cs file in Migrations folder.

AutomaticMigrationsEnabled = true;

Please for the love of God don’t go for drop and recreate database option, as you will lose data when accidentally code is moved to staging or production, code as given below(Warning, You will lose data by using this)

Database.SetInitializer<NameOfDbContext>(new DropCreateDatabaseIfModelChanges<NameOfDbContext>());

Visit Stack Over flow for more discussion.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: