In my ASP.NET Core application, I have two application settings, one for production and one for development. I'm also using database migrations to manage my database, that said, with their being two connection strings I can only update the development database from Visual Studio. My question is, is it possile to run database migrations against two connections strings? i.e. the connections strings I have stored in appsettings.Production.json
and appsettings.Development.json
?
appsettings.Development.json
{
"ConnectionStrings": {
"DevConnection": "Server=tcp:devdatabase.database.windows.net,1433;Initial Catalog=MyDevelopment;Persist Security Info=False;User ID=whatever;Password=whatever;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;",
},
"AllowedHosts": "*"
}
appsettings.Production.json
{
"ConnectionStrings": {
"ProdConnection": "Server=tcp:proddatabase.database.windows.net,1433;Initial Catalog=MyProduction;Persist Security Info=False;User ID=whatever;Password=whatever;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;",
},
"AllowedHosts": "*"
}
Both my database are stored in Azure, typically if I'm wanting to make changes I'll create a migration in the following manner:
Add-Migration AddedBoolColumns
Followed by
Update-Database
The migration takes the development connection string and updates the development database but production remains unchanged and sometimes I want those changed to carry to that database as well. Is there a way this can be done?