2

I can add a "ConnectionStrings" element to my appsettings.json file; however, when I copy and paste the same element in to my appsettings.Development.json file it doesn't seem to work. My var connection = Configuration.GetConnectionString("DefaultDatabase"); line of code no longer works within Startup.cs and the ConfigureServices() method.

I am using Visual Studio 2017 and when i go to the properties of the project and go to the Debug tab I can see that it is setting ASPNETCORE_ENVIRONMENT to Development so shouldn't the connection string within appsettings.Development.json work with the Conifugration.GetConnectionString() method?

1 Answer 1

3

Ugh ok apparently I was pasting the code in to the "Logging" section element (right after the LogLevel element. Now that I truly have ConnectionStrings as its own element instead of a property of Logging all is well now.

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

Comments

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.