What is Entity Frameworks mechanism to prevent multiple executions of the same migration?

和自甴很熟 提交于 2019-12-13 16:15:36

问题


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?


回答1:


Although some migration steps one by one run in a separate transaction, the situation is not simple. Not only two (or more) migration step, but migration step and the normal program running can interfere.

Link: It's a bit old, but can useful

update: ideas may be here:

  • Martin Fowler: BlueGreenDeployment
  • Zero Down-time – relational databases
  • Day 3 - Zero-Downtime MySQL Schema Changes


来源:https://stackoverflow.com/questions/18701911/what-is-entity-frameworks-mechanism-to-prevent-multiple-executions-of-the-same-m

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!