title: Winforms - program cannot find connection string from app.config
body: <p>I am using VS 2013. I am trying to use SQL Server Compact with Entity Framework 6. Created database and <code>.EDMX</code> model in VS 2012 and opened in VS 2013. I installed latest EF and EF SQL.CE from NuGet. When I try to run I am getting the following error </p>
  
  <blockquote>
    <p>No connection string named 'SomeDbFile' could be found in the application config file.</p>
  </blockquote>
  
  <p><code>app.config</code>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;configuration&gt;
      &lt;configSections&gt;
          &lt;section name="entityFramework" 
                   type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /&gt;
      &lt;/configSections&gt;
      &lt;entityFramework&gt;
          &lt;defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework"&gt;
              &lt;parameters&gt;
                  &lt;parameter value="System.Data.SqlServerCe.4.0" /&gt;
              &lt;/parameters&gt;
          &lt;/defaultConnectionFactory&gt;
          &lt;providers&gt;
              &lt;provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /&gt;
              &lt;provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" /&gt;
          &lt;/providers&gt;
      &lt;/entityFramework&gt;
      &lt;system.data&gt;
          &lt;DbProviderFactories&gt;
              &lt;remove invariant="System.Data.SqlServerCe.4.0" /&gt;
              &lt;add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" /&gt;
          &lt;/DbProviderFactories&gt;
      &lt;/system.data&gt;
      &lt;connectionStrings&gt;
          &lt;add name="SomeDbFile" 
               connectionString="metadata=res://*/EDataModel.csdl|res://*/EDataModel.ssdl|res://*/EDataModel.msl;provider=System.Data.SqlServerCe.4.0;provider connection string=&amp;quot;data source=|DataDirectory|\dbfile.sdf&amp;quot;" 
               providerName="System.Data.SqlServerCe.4.0" /&gt;
      &lt;/connectionStrings&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Generated <code>DbContext</code>:</p>
  
  <pre><code>public partial class Entities : DbContext
  {
      public Entities() : base("name=SomeDbFile")
      {
      }
  
      protected override void OnModelCreating(DbModelBuilder modelBuilder)
      {
          throw new UnintentionalCodeFirstException();
      }
  
      public DbSet&lt;category&gt; category { get; set; }
      public DbSet&lt;item&gt; item { get; set; }
      public DbSet&lt;order&gt; order { get; set; }
      public DbSet&lt;order_line&gt; order_line { get; set; }
  }
  </code></pre>