I am currently using auto-migrations with the following powershell console commands: add-migration update-database
I would like to know if there is an option to update the database automatically if the model changes (DbContext) without using the console commands.
Thanks.
I use
public class DataContext : DbContext
{
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
Database.SetInitializer(new MigrateDatabaseToLatestVersion<DataContext,Configuration>());
base.OnModelCreating(modelBuilder);
}
}
This causes the database migrations to the latest version when the data context is created at code runtime.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.