title: Accessing the connection string in Entity Framework Core 6
body: <p>I'm doing my first app in .NET 6 and using Entity Framework Core 6, using database first and the <code>Scaffold-DbContext</code> command to create the <code>DbContext</code>.</p>
  <p>The only issue I have is trying to use the <code>Name={connection string name}</code> parameter rather than embedding the connection string. The app is a simple Console app (not an ASP.NET app) with an <code>app.config</code> file (can't use a JSON config file for other reasons). I added the connection to the config file like:</p>
  <pre><code>&lt;connectionStrings&gt;
      &lt;add name=&quot;MyDatabase&quot; 
           connectionString=&quot;Server=xxxxxxx;Database=xxxxxxx;Trusted_Connection=True&quot;/&gt;
  &lt;/connectionStrings&gt;
  </code></pre>
  <p>I get this error:</p>
  <blockquote>
  <p>A named connection string was used, but the name 'ClientServices' was not found in the application's configuration. Note that named connection strings are only supported when using 'IConfiguration' and a service provider, such as in a typical ASP.NET Core application. See <a href="https://go.microsoft.com/fwlink/?linkid=850912" rel="nofollow noreferrer">https://go.microsoft.com/fwlink/?linkid=850912</a> for more information.</p>
  </blockquote>
  <p>What do I need to do so that the <code>Scaffold-DbContext</code> <code>Name</code> parameter can find my connection string? Looked at the link in the error, but it didn't help - was for ASP.NET apps.</p>