title: Issue with different Entity Framework connection strings in web.config and app.config
body: <p>My solution has two projects. A class library to generate data from an Entity Framework .edmx file via a repository class. The App.Config file connectionString matches the Web.config in my second ASP.Net 4.0 web forms project.</p>
  
  <p>I modify BOTH connectionStrings to point to the test database (DataSource=TestDB) when deployed to the test server. When deployed to the live site I modify both to point to the live database (DataSource=LiveDB).</p>
  
  <p>At the top of Site.Master I display in red letters "You are connected to the TEST database" in a label control. I conditionally toggle the .Visible property of the label <code>if (context.Connection.DataSource.Contains("TestDB"))</code></p>
  
  <p>During development I noticed something strange. When Web.config points to TestDB, if I forget to make App.config match (and it points to LiveDB) the "connected to TEST" warning appears but data from LiveDB displays.</p>
  
  <p>This tells me the repository (class library) uses App.Config but a data context created in the web forms project uses the Web.config connectionString. Is that correct? I'm concerned that live data will be updated incorrectly if I deploy to the test site and forget to point App.Config to TestDB.</p>
  
  <p>So my question is, in this scenario... <strong>What is the best way to display a notification "connected to test database" that is always accurate?</strong></p>