Is there any code to perform automatic migration in Entity Framework core
code first
in asp.net core project?
I do it simply in MVC4/5 by adding
Database.SetInitializer(new MigrateDatabaseToLatestVersion<AppDbContext, MyProject.Migrations.Configuration>());
public Configuration() {
AutomaticMigrationsEnabled = true;
}
This saves time when entities changed
You can call context.Database.Migrate()
in your Startup.cs
eg:
using (var context = new MyContext(...))
{
context.Database.Migrate();
}