I have two configurations: - Development - Production
with following json settings files: - appsettings.Production.json - appsettings.Development.json
In each settings file I have following sections:
(production)
"Sql" : {
"Name": "App_Prod",
"Server": "127.0.0.1",
"Port": 0,
"Database": "db_prod",
"Username": "user_prod",
"Password": "secret"
},
(development)
"Sql" : {
"Name": "App_Dev",
"Server": "127.0.0.1",
"Port": 0,
"Database": "db_dev",
"Username": "user_dev",
"Password": "secret"
},
I'm injectings these into my DbContext constructor, and it works properly. I updated my database using migrations system using foolowing command:
dotnet ef database update --context MyDbContext--configuration Development
it worked, and my database scheme has been updated.
But when I'm trying to update my production database using following commanad:
dotnet ef database update --context MyDbContext--configuration Production
it gaves me information that any migrations no needs to be applied.
I dumped connection string in MyDbContext, and I can see that the DbContext still use Development configuration even I type that it should be use Production settings file.
Why migration mechanism does not respect my configuration? How I can run dotnet ef with appsettings.Production?