title: Store / Retrieve ConnectionString from appSettings.json in ASP.net Core 2 MVC app
body: <p>I'm looking for the <strong>best practice</strong> way to store a connection string in appsettings.json in a .net Core 2 MVC app (like you do in web.config in MVC 5).</p>
  
  <p>I want to use Dapper not EF (I found many EF examples).</p>
  
  <p>Something like this:</p>
  
  <pre><code>{
    "ConnectionStrings": {
      "myDatabase": "Server=.;Database=myDatabase;Trusted_Connection=true;"
    },
  
    "Logging": {
      "IncludeScopes": false,
      "LogLevel": {
        "Default": "Warning"
      }
    }
  }
  </code></pre>
  
  <p>Surely there are many examples online? Nothing I can find that is for .net core 2.0.</p>
  
  <p>Several things have changed between 1 and 2 and I want to ensure I'm using version 2 best practices.</p>
  
  <p>I've found this - but it seems to be .net core 1:
  <a href="https://www.youtube.com/watch?v=GUbnfNCqyXw" rel="noreferrer">Visual Studio 2017 - MVC Core - Part 05 - Connection String from appsettings.json</a></p>
  
  <p>This uses key value pair appsettings - not the connectionstrings:
  <a href="http://edi.wang/post/2016/10/9/read-appsettings-aspnet-core" rel="noreferrer">Read AppSettings in ASP.NET Core 2.0</a></p>
  
  <p>Again it's unclear if this is .net Core 1 or 2: <a href="https://stackoverflow.com/questions/46187522/net-core-connection-string-dapper-visual-studio-2017">Net Core Connection String Dapper visual studio 2017</a></p>