Search code examples
entity-frameworkasp.net-mvc-4connection-stringdatabase-first

Connection Strings - MVC Entity Framework - Database First


Can anyone suggest how I could programatically switch debug and live connection strings?

I've seen other people have passed an EntityConnection to the constructor from the controller like this :

private XYZDatabase db = new XYZDatabase(ConfigurationManager.
ConnectionStrings["XYZDatabase-TEST"].ConnectionString);

but it still requires manually changing it? is there a way to use

System.Net.Dns.GetHostName() or similar to switch it automatically?

Thanks


Solution

  • Ayende has a post that addresses this issue.

    http://ayende.com/blog/135169/frictionless-development-web-config-and-connection-strings