title: ASP.NET 5 / MVC 6 Database First - No connection string named MyEntity could be found in the application config file
body: <p>Our ASP.NET 5 / MVC 6 project accesses our DB by going through a Business layer assembly then down into DAL (Database First) assembly.  The MVC 6 code blows up when trying to execute the Business layer code which uses the DbContext to access the DB with error: No connection string named 'MyEntity' could be found in the application config file.  I have tried defining the MyEntity connection string in the MVC project config.json, appsettings.json in various ways with no luck.</p>
  
  <p>If executing Business layer methods from a tester project where I have the expected app.config file with connection string syntax as below it works no problem.  </p>
  
  <p><strong>Note</strong> This question could also be restated as how to migrate a MVC 5 to MVC 6 app, where the MVC 5 app loosely coupled DB access to DAL layer and the MVC code had NO knowledge of EF and ONLY supplied the web.config connection string needed by DbContext object in DAL?</p>
  
  <p>Any help would be appreciated, let me know if you need any more information.</p>
  
  <p>Config file syntax in Tester project: </p>
  
  <pre><code>&lt;add name="MyEntity" 
  
  connectionString="metadata=res://*/MyModel.csdl|res://*/MyModel.ssdl|res://*/MyModel.msl;provider=System.Data.SqlClient;provider connection string=&amp;quot;data source=MyServer;initial catalog=MyDB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&amp;quot;" 
  providerName="System.Data.EntityClient" /&gt;
  </code></pre>
  
  <p>Likely wrong syntax in config.json file.</p>
  
  <pre><code>{
    "Data": {
  
  "defaultConnection": {
  
  "connectionString": "metadata=res://*/MyModel.csdl|res://*/MyModel.ssdl|res://*/MyModel.msl;provider=System.Data.SqlClient;provider connection string=&amp;quot;data source=MyServer;initial catalog=MyDB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&amp;quot;"
      },
  
  "entityFramework": {
  
  "MyEntity": {
  
  "ConnectionString": "name=data:defaultConnection:connectionString"
        }
      }
    }
  }
  </code></pre>