I am trying to find the best way to migrate my database in my production environment, and I think I'm losing some of the terminology.
I have a class called "Migration" that I use to load my database. The constructor looks like this (my DbContext is called SiteDatabase):
internal sealed class Migration : DbMigrationsConfiguration<SiteDatabase>
{
public Migration()
{
AutomaticMigrationsEnabled = true;
AutomaticMigrationDataLossAllowed = true;
}
}
- What does AutomaticMigrationsEnabled do here? Is this how I turned on automatic migrations?
In my Application_Start () method, I saw the following elements added:
protected void Application_Start()
{
new DbMigrator(new Migration()).Update();
Database.SetInitializer(new MigrateDatabaseToLatestVersion<SiteDatabase, Migration>());
Database.SetInitializer(new DropCreateDatabaseAlways<SiteDatabase>());
}
- Are only these options available?
- How does this relate to AutomaticMigrationsEnabled, what's in the migration class?
In the package manager console, I know about the following commands:
> update-database
> add-migration
- AutomaticMigrationsEnabled? ? DbMigrator?
- add-migration, ? , , .
- , , add-migration, ?