title: EF Core set connection string
body: <p>I have a database project that's used by other dotnet projects (azure function app and a web app). I want to use <strong>dotnet ef core cli</strong> to work with migrations, but I don't want to keep my connection string in-code (I want to my repo to be public).</p>
  
  <p>Here's my current DbContext:</p>
  
  <pre><code>public ChadwickDbContext(DbContextOptions options): base(options) {}
  </code></pre>
  
  <p>When I run something like:
  <code>dotnet ef migrations add InitialCreate</code></p>
  
  <p>I get the error:</p>
  
  <blockquote>
    <p>Unable to create an object of type 'ChadwickDbContext'. For the
    different patterns supported at design time, see
    <a href="https://go.microsoft.com/fwlink/?linkid=851728" rel="nofollow noreferrer">https://go.microsoft.com/fwlink/?linkid=851728</a></p>
  </blockquote>
  
  <p>This worked previously because I had the connection string hard coded like this:</p>
  
  <pre><code>public ChadwickDbContext(string connectionString = "&lt;connection string&gt;"): base(GetOptions(connectionString)) {}
  </code></pre>
  
  <p>Is there any way to <strong>set</strong> the connection string via the <strong>cli</strong> or include some sort of environment file like <code>appsettings.json</code> in a database-only project?</p>
  
  <p><a href="https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/dotnet#dotnet-ef-dbcontext-scaffold" rel="nofollow noreferrer">Scaffolding</a> seems to be close to what I want, but that appears to be more of a way to <em>generate</em> your context and models (which is already done).</p>