[英]How to fire migration where connection string is in database
In my application, there are multiple tenants and for each tenant we have created new database. 在我的应用程序中,有多个租户,并且为每个租户创建了新数据库。 So for new development, when we need to change some table structure we need to fire migration commands for each tenant db.
因此,对于新开发,当我们需要更改某些表结构时,我们需要为每个租户数据库触发迁移命令。
Is there any way to execute migration command on dynamic connection strings in one shot? 一口气可以对动态连接字符串执行迁移命令吗? Our connection string is in DB.
我们的连接字符串在DB中。
Thanks in advance. 提前致谢。
I think it is not possible to execute migrations on several databases in one shot. 我认为不可能一口气在多个数据库上执行迁移。 You have to call the migration command for every single connection string in a loop.
您必须为循环中的每个单个连接字符串调用迁移命令。
You can either call it programatically with C# or create a Powershell script that runs migrate.exe. 您可以使用C#以编程方式调用它,也可以创建运行migration.exe的Powershell脚本。
We use the second option in our deployment, so that database migrations are an explicit step in the release pipeline. 我们在部署中使用第二个选项,因此数据库迁移是发布管道中的明确步骤。
Migrate.exe has a parameter to provide the connection string. Migrate.exe具有提供连接字符串的参数。 See here for more details.
请参阅此处了解更多详细信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.