specify appsettings while adding database migration

asp.net-core asp.net-core-mvc c# entity-framework-core

Question

appsettings files

  1. appsettings.json
  2. appsettings.Production.json
  3. appsettings.Test.json
  4. appsettings.Debug.json

all for specific environment but first for common settings.

appsettings.json file does not contain connection string, since each environment has its own db.

running add-migration mig-1 obviously complains that

Could not find a connection string named 'ConnectionString'.

How can i specify connection string to be taken from appsettings.Test.json instead of default one (appsettings.json)

1
0
7/28/2017 10:25:21 AM

Accepted Answer

Found answer in docs

add-migration mig-1 -e Test    

Note

EF Core 1.x CLI tools supported an argument called environment which could be use to specify the environment when the commands were run against an ASP.NET Core application. This argument is no longer available in 2.0:

-e|--environment <NAME>  The environment to use. Defaults to "Development".

With 2.0, you can use the ASPNETCORE_ENVIRONMENT environment variable instead.

1
10/3/2017 9:26:09 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow