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.
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).
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 if (context.Connection.DataSource.Contains("TestDB"))
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.
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.
So my question is, in this scenario... What is the best way to display a notification "connected to test database" that is always accurate?