title: Entity Framework Can't Find Connection String in Web.config
body: <p>Entity Framework doesn't seem to actually be reading connection strings from the Web.config.</p>
  
  <p>I started a new project and created a context:</p>
  
  <pre><code>public class FooContext : DbContext
  {
      public FooContext() :
          base("Foo")
      {
      }
  
      // DbSets here
  }
  </code></pre>
  
  <p>Then, I added a connection string to the projects Web.config:</p>
  
  <pre><code>&lt;configuration&gt;
    &lt;configSections&gt;
      &lt;!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --&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;connectionStrings&gt;
      &lt;add name="Foo" providerName="System.Data.SqlClient" connectionString="Data Source=Foo;Initial Catalog=Foo;Integrated Security=False;User Id=foo;Password=foo;MultipleActiveResultSets=True" /&gt;
    &lt;/connectionStrings&gt;
    &lt;appSettings&gt;
        ...
  </code></pre>
  
  <p>I enabled migrations, generated an initial migration, and then attempted to update the database. After a while, the update fails saying that it couldn't connect to the database. So I pulled my project DLL into LINQPad and ran the following:</p>
  
  <pre><code>var context = new FooContext();
  context.Database.Connection.ConnectionString.Dump();
  </code></pre>
  
  <p>And I get the following output:</p>
  
  <pre><code>Data Source=.\SQLEXPRESS;Initial Catalog=Foo;Integrated Security=True;MultipleActiveResultSets=True
  </code></pre>
  
  <p>It's trying to connect to LocalDB, completely ignoring my connection string. So I tried being more explicit in the context constructor, by using <code>"name=Foo"</code> instead of just <code>"Foo"</code>.</p>
  
  <pre><code>public FooContext() :
      base("name=Foo")
  {
  }
  </code></pre>
  
  <p>For what it's worth, I've never had to do this before. I've even got other projects in the same solution where the I've simply passed the connection string name and they've been working fine.</p>
  
  <p>I jump back over to LINQPad and run the code again, and now I get an exception:</p>
  
  <pre><code>No connection string named 'Foo' could be found in the application config file.
  </code></pre>
  
  <p>I'm at a complete loss. I've set up projects like this 100s of times and never had any issues. Since it may be important, I'm running the latest Entity Framework, 6.1.3. Any ideas what could possibly be going on here?</p>