Update-Database tries to do an automatic migration even with automatic migrations disabled
I hate to answer my own question but I encountered this problem again. A developer on my team re-enabled automatic migrations on their local machine and then created an explicit migration, which reproduced this behavior as soon as I ran it.
Entity framework will always run an automatic migration before it runs an explicit migration that has the Source
property defined in its .resx
file, even if AutomaticMigrationsEnabled = false
. An explicit migration will only have the Source
property set if it is created after an automatic migration has been run.
The upshot is that disabling automatic migrations only means that EF won't automatically upgrade your schema when it detects model changes - but it might still do an automatic migration if it needs to fill in a gap between some explicit migrations. To avoid this behavior, don't use a mixture of automatic migrations and explicit migrations.
public class Configuration : DbMigrationsConfiguration<bailencasino.com.dal.Context.BlncnoContext>
{
public Configuration()
{
AutomaticMigrationsEnabled = false;
AutomaticMigrationDataLossAllowed = true;
}
Add AutomaticMigrationDataLossAllowed = true;
so you assume that you want to allow EF to add remove SQL objects that result in data loss.