3

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 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

1 Comment

FYI, in EF Core 2.0.0, you'll need to set the ASPNETCORE_ENVIRONMENT environment variable instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.