title: Entity Framework - using the same DbContext with different connection strings
body: <p>I'm currently trying to use the same DbContext (I have two databases, of identical structure) in my application. I'm not quite sure what I'm doing wrong, but here's my current code - hopefully it should be pretty obvious what I'm trying to do. I'm using EF Database First (which the error at the bottom seems not to suggest).</p>
  
  <p>My context factory code:</p>
  
  <pre><code>public class HOLContextFactory
      {
          public static HOLDbEntities Create()
          {
              return new HOLDbEntities(); // Works
          }
  
          public static HOLDbQuoteEntities CreateQuote()
          {
              return new HOLDbQuoteEntities(); // Gives error
          }
      }
  
  public partial class HOLDbQuoteEntities : HOLDbEntities
      {
          public HOLDbQuoteEntities()
              : base("HOLDbQuoteEntities") // This should send "HOLDbQuoteEntities" as the base connection string?! 
  // Also tried "name=HOLDbQuoteEntities"
              {
              }
          }
  </code></pre>
  
  <p>Web.config connection strings:</p>
  
  <pre><code>&lt;add name="HOLDbEntities" connectionString="metadata=res://*/HOLDbContext.csdl|res://*/HOLDbContext.ssdl|res://*/HOLDbContext.msl;provider=System.Data.SqlClient;provider connection string=&lt;connstringdetails&gt;" providerName="System.Data.EntityClient" /&gt;
  
  &lt;add name="HOLDbQuoteEntities" connectionString="metadata=res://*/HOLDbContext.csdl|res://*/HOLDbContext.ssdl|res://*/HOLDbContext.msl;provider=System.Data.SqlClient;provider connection string=&lt;connstringdetails&gt;" providerName="System.Data.EntityClient" /&gt; // using diff database - same structure
  </code></pre>
  
  <p>Error I'm getting when using "HOLDbQuoteEntities" :</p>
  
  <blockquote>
    <p>Code generated using the T4 templates for Database First and Model
    First development may not work correctly if used in Code First mode.
    To continue using Database First or Model First ensure that the Entity
    Framework connection string is specified in the config file of
    executing application. To use these classes, that were generated from
    Database First or Model First, with Code First add any additional
    configuration using attributes or the DbModelBuilder API and then
    remove the code that throws this exception**</p>
  </blockquote>