EF Core在迁移期间锁定数据库 [英] EF Core lock the database during migration

查看:121
本文介绍了EF Core在迁移期间锁定数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过 Database.Migrate()运行迁移时,是否可以从其他任何连接中锁定数据库?



我们有多个服务实例(在AWS Lambda上)运行相同的代码,并在启动时进行迁移。现在,当我们要应用某些迁移时,我们必须手动确保只有一个实例正在运行,否则它们都可以尝试这样做并破坏了性能。



是否有数据库级别的解决方案?



ef-core 2.1

解决方案

不是很确定这是否是您要查找的,但是如果您愿意添加普通的 SQL 迁移时,您可以将数据库设置为单用户模式:了解详情


Is it possible lock the database from any other connections when running the migrations through Database.Migrate()?

We have multiple service instances running the same code (on AWS Lambda), and do the migrations on startup. Now we have to manually make sure that only one instance is running when we want to apply some migrations, otherwise they can both try to do it and break things bad.

Is there a database level solution to this?

ef-core 2.1

解决方案

Not really sure if this is what you are looking for, but if you are willing to add plain SQL to your migration you could set database to single user mode: Read more

这篇关于EF Core在迁移期间锁定数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆