Of course EF is storing the latest migration to the MigrationHistory table to determine if a specific migration was already executed.
My question is about what EF is doing to prevent multiple executions of the same migration at the same time. Assuming you have two applications which runs under different application domains using the same database. Both apps are starting simultaneously, wherefore both starts to migrate to the latest database migrations. Assume MigrateDatabaseToLatestVersion
is set as the initializer.
I think the migration started last fails cause the first executed migration updated the MigrationHistory table just before. Does EF relies here on SQLs transactions to rollback the migration which was too late? Or does it use a smarter mechanism to prevent the execution of the second migration?