title: EF Core2.2: Scaffold-DbContext not working with named connection string in WPF project
body: <p>I want to work with EF Core 2.2 and Database first in my .net Framework 4.7 project. it works fine running this command:</p>
  
  <pre><code>Scaffold-DbContext "data source=dbServer;initial catalog=myData;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Database
  </code></pre>
  
  <p>but then MS puts down this warning:</p>
  
  <blockquote>
    <p>warning To protect potentially sensitive information in your connection string, you should move it out of source code. See  <a href="http://go.microsoft.com/fwlink/?LinkId=723263" rel="noreferrer">http://go.microsoft.com/fwlink/?LinkId=723263</a> for guidance on storing  connection strings.</p>
  </blockquote>
  
  <p>So i thought I do as told and updated the script as follows:</p>
  
  <pre><code>Scaffold-DbContext "name=MyConnection" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Database
  </code></pre>
  
  <p>which results in this error:</p>
  
  <blockquote>
    <p>A named connection string was used, but the name 'MyConnection' 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="noreferrer">https://go.microsoft.com/fwlink/?linkid=850912</a> for more information.</p>
  </blockquote>
  
  <p>The named connection itself works fine, I have tested that by commennting out the first line that was generated by EF core and making use of the second line:</p>
  
  <pre><code>//optionsBuilder.UseSqlServer("data source=dbServer;initial catalog=myData;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework");
              optionsBuilder.UseSqlServer(ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString);
  </code></pre>
  
  <p>starting the program it can connect and display the data as expected. But I would prefer to have that setting alrady in Scaffold-DbContext.  Any ideas?</p>
  
  <p>For completeness sake here's the app.config:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
    &lt;configuration&gt;
      &lt;connectionStrings&gt;
         &lt;add name="MyConnection" connectionString="data source=dbServer;initial catalog=myData;integrated security=True;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" /&gt;
      &lt;/connectionStrings&gt;
   &lt;/configuration&gt;
  ...
  </code></pre>