title: Entity framework 4.1 modify connection string for each developers unit test environment
body: <p>We have an Entity framework 4.1 setup, auto generated POCOs and DbContext classes for interaction with the db.</p>
  
  <p>The automatically generated DbContext derived class looks like this:</p>
  
  <pre><code> public MyEntities()
          : base("name=MyEntities")
      {
      }
  </code></pre>
  
  <p>And the automatically generated connection string in app.config something like:</p>
  
  <pre><code>&lt;connectionStrings&gt;
      &lt;add name="MyEntities" connectionString="blah blah blah"  providerName="System.Data.EntityClient" /&gt;
  &lt;/connectionStrings&gt;
  </code></pre>
  
  <p>That's all fine, and works right out of the box.</p>
  
  <p>Each of our developers has their own SQL Developer edition install for unit testing and dev purposes, so they need to modify the connection string to point to their installation when doing unit testing. These connection strings are in the App.config file of the unit test project</p>
  
  <p>This is currently a manual modification step, and I had thought to automate this in some way.</p>
  
  <p>Now, I can go and work out the connection string in code, but passing this into the entity framework constructor is prevented by the default auto-generated "MyEntities" constructor above - it doesn't have a connection string parameter on any constructor. (Although DbContext does). Furthermore, I don't particularly want to plumb the connection string through the DAL code and down into the entity framework code - that isn't needed in production, so that's modifying my code just for the purposes of unit test.</p>
  
  <p>I had thought there must be some way to override the string in App.config.
  This would be similar to how this can be done with a local Appsettings file.
     <code>(ie &lt;appSettings file="Local.config"/&gt;)</code>, but I can't seem to see how to do this for the ConfigurationManager.ConnectionStrings entries.</p>
  
  <p>So, what does one do here? </p>