Is there any way to disable migration in Entity Framework 4.3.1? I removed the migrations folder from the project and the generated tables in my database, but it doesn't work! How can you remove the migration?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
If you don't want to use migrations but in the same time you want EF to create database for you, you just need to set correct database initializer:
Database.SetInitializer<YourContextType>(new CreateDatabaseIfNotExists<YourContentType>());
回答2:
Deleting the Migrations
folder has worked for me. I don't get any errors, it puts me back to where I started.
回答3:
The way that I got around this was to make sure that I turned off Automatic Migrations in my code:
internal sealed class Configuration : DbMigrationsConfiguration<YourContext>
{
public Configuration()
{
AutomaticMigrationsEnabled = false;
}
}
and then I deleted the _MigrationHistory table from the database (this is usually created as a system table if you can't find it)