I'm trying to figure out how to create a dynamic context, and what I mean by that is I have two databases: one for testing, and one for production. Depending on where my website is hosted, I want my context to be pointing at one of the two. So, in my web.config I have:
<add name="Testing_ChannelsEntities" connectionString="removed for brevity" providerName="System.Data.EntityClient" />
<add name="Production_ChannelsEntities" connectionString="removed for brevity" providerName="System.Data.EntityClient" />
Please don't get hung-up on the fact that I removed the connectionString for this example. Just note that I have a testing and a production connection in the web.config.
So, here is my codebehind that I would expect to create a context to the testing connectionString:
using (ChannelsEntities chEntity = new ChannelsEntities("Testing_ChannelsEntities")) {
// removed the business logic because it's not relevant at all
}
Once execution hits the using statement, I get the following error:
Format of the initialization string does not conform to specification starting at index 0.
What am I missing here? This should be easy to do.