title: Using C# MVC4 and Matching DbContext Class name with ConnectionString name to use the right database?
body: <p>Using EF Code First, I know that I have to match my <code>DbContext</code> class name with the database's connection string <code>name</code> attribute to make them work together. But the following code does not work:</p>
  
  <pre><code> public class UserDbContext : DbContext
           {
               public DbSet&lt;Users&gt; Users { get; set; }
           }
  </code></pre>
  
  <p>along with this connection string:</p>
  
  <pre><code>&lt;add name="UserDbContext" 
   connectionString="Data Source=(LocalDB)\v11.0;
   AttachDbFilename=|DataDirectory|\Users.mdf;
   Integrated Security=True" 
   providerName="System.Data.SqlClient" /&gt;
  </code></pre>
  
  <p>But instead I end up having to use this connection string instead, which points directly to the model along with the <code>DbContext</code> name</p>
  
  <pre><code>&lt;add name="NextFlicksMVC4.Models.userAccount.Users+UserDbContext"     
   connectionString="Data Source=(LocalDB)\v11.0;
   AttachDbFilename=|DataDirectory|\Users.mdf;
   Integrated Security=True"
   providerName="System.Data.SqlClient" /&gt;
  </code></pre>
  
  <p>It works as intended, I connect to a LocalDB in the App_Data Folder. </p>
  
  <p>Can anyone explain to me why it only works when I point it to the full path of the DbContext class?</p>