Hi guys, now I want to share how to execute ef-core migrations with different appsettings.json files, to change the string connection to execute migrations according to the environment.
Supposing that you have different string connections for each environment that you have, for example: development, staging, production; you could have three appsettings.
- appsettings.development.json
- appsettings.staging.json
- appsettings.production.json
If you want to execute migrations with each connection string declared in those files, you need to execute the following command in package manager console.
$env:ASPNETCORE_ENVIRONMENT='Production'
and then you could call Update-Database to execute migrations with the associated environment.
I hope that post could help you. Don’t forget to check my previous post
Execute ef-core migrations with different settings