问题描述
当然EF正存储最新迁移到MigrationHistory表,以确定是否已经执行一个特定的迁移
Of course EF is storing the latest migration to the MigrationHistory table to determine if a specific migration was already executed.
我的问题是关于什么的EF做以prevent相同迁移多个执行在同一时间。假设你有两个应用场合下使用相同的数据库不同的应用领域中运行。这两个应用程序同时启动,因此两者开始迁移到最新的数据库迁移。假设 MigrateDatabaseToLatestVersion
设置为初始化。
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.
我想迁移始于去年出现故障导致第一个执行迁移之前更新MigrationHistory表。请问EF依靠这里sql语句的事务回滚这是为时已晚的迁移?抑或是使用prevent一个更聪明的机制,第二个迁移的执行?
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?
推荐答案
尽管一些迁移步骤逐一运行在单独的事务,情况并不简单。不仅两个(或更多)的迁移步骤,但迁移步骤和正常的程序运行的干扰。
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.
链接:这是一个有点老,但也有用
更新:想法可能是在这里:
update: ideas may be here:
- Martin Fowler: BlueGreenDeployment
- Zero Down-time – relational databases
- Day 3 - Zero-Downtime MySQL Schema Changes
这篇关于什么是实体框架机制,以同样的迁移prevent多次执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!