title: Can't read app settings in .NET Core API project
body: <p>I have a .NET Core API project and I am trying to read some settings from the <em>appsettings.json</em> file.</p>
  
  <p>The file looks like this:</p>
  
  <pre><code>{
    "Logging": {
      "IncludeScopes": false,
      "Debug": {
        "LogLevel": {
          "Default": "Warning"
        }
      },
      "Console": {
        "LogLevel": {
          "Default": "Warning"
        }
      }
    },
    "ConnectionString": "abc"
  }
  </code></pre>
  
  <p>and I am trying to read the <code>ConnectionString</code> setting like this:</p>
  
  <pre><code>ConfigurationManager.AppSettings["ConnectionString"];
  </code></pre>
  
  <p>but I get <code>null</code>, and apparently no app settings have been detected at all.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Here is what I have now:</p>
  
  <p><em>startup.cs</em></p>
  
  <pre><code>public class Startup
      {
          public Startup(IConfiguration configuration)
          {
              Configuration = configuration;
          }
  
          public static IConfiguration Configuration { get; set; }
  
          // This method gets called by the runtime. Use this method to add services to the container.
          public void ConfigureServices(IServiceCollection services)
          {
              services.AddDbContext&lt;MyContext&gt;();
              services.AddMvc();
              services.Configure&lt;ConnectionStringSettings&gt;(Configuration);
          }
  }
  </code></pre>
  
  <p><em>ConnectionStringSettings.cs</em></p>
  
  <pre><code> public class ConnectionStringSettings
      {
          public string ConnectionString { get; set; }
      }
  </code></pre>
  
  <p><em>appsettings.json</em></p>
  
  <pre><code>{
    "Logging": {
      ...
    },
    "ConnectionStrings": {
      "Debug": "abc"
    }
  }
  </code></pre>
  
  <p><em>MyContext.cs</em>
  public class MyContext : DbContext
      {
          string x;</p>
  
  <pre><code>    public MyContext() { }
  
      public MyContext(DbContextOptions&lt;MyContext&gt; options)
          : base(options) { }
  
      public MyContext(IOptions&lt;ConnectionStringSettings&gt; connectionStringSettings)
      {
          x = connectionStringSettings.Value.ConnectionString;
      }
  
      protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
      {
         //here I need my connection string
          optionsBuilder.UseMySql(connectionString);
      }
  </code></pre>
  
  <p>}</p>