-->

EF Core lock the database during migration

2019-07-21 02:11发布

问题:

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

回答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