title: Entity Framework 6 - can't connect to database server
body: <p>This row causes the exception:</p>
  
  <pre><code>var query = from customer in ctx.Customers select customer;
  </code></pre>
  
  <p>Exception:</p>
  
  <blockquote>
    <p>An unhandled exception of type 'System.Data.Entity.Core.ProviderIncompatibleException' occurred in EntityFramework.dll</p>
    
    <p>An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct.</p>
  </blockquote>
  
  <p>Connection string from <code>Database.Connection.ConnectionString</code>:</p>
  
  <pre><code>Data Source=.\SQLEXPRESS;Initial Catalog=Customer.CustomersContext;Integrated Security=True;MultipleActiveResultSets=True
  </code></pre>
  
  <p><code>App.config</code>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;configuration&gt;
    &lt;entityFramework&gt;
      &lt;defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"&gt;
        &lt;parameters&gt;
          &lt;parameter value="v11.0" /&gt;
        &lt;/parameters&gt;
      &lt;/defaultConnectionFactory&gt;
    &lt;/entityFramework&gt;
    &lt;connectionStrings&gt;
    &lt;add name="Customer.CustomersContext" providerName="System.Data.SqlClient" connectionString="Data Source=(localdb)\Projects;Initial Catalog=master;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False" /&gt;
  &lt;/connectionStrings&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p><code>Context</code> class:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Data.Entity;
  
  namespace Customer
  {
      class CustomersContext : DbContext
      {
          public CustomersContext() : base("Customer.CustomersContext")
          {
              System.Console.WriteLine(Database.Connection.ConnectionString);
          }
  
          public DbSet&lt;CustomerDb&gt; Customers { get; set; }
          public DbSet&lt;Contact&gt; Contacts { get; set; }
      }
  }
  </code></pre>
  
  <p>You can see I even tried to pass connection string name from <code>app.config</code> to context constructor (localdb should be used), but the printed connection string is still <code>SQLExpress</code>.</p>