Visual Studio 2013 Ultimate, WinForms .Net 4.5.1 and Entity Framework 6.1.1 Code First
Application requires a change to app.config connection string while the application is running when a db server is not present. Code works great at updating the App.Config, saving it and refreshing it. The ConfigurationManager has no problem seeing the new connection string. ADO.Net has no issue reading in the new SQL Connection string however when I apply this to Entity Framework the connection string is not updated.
It appears that on load EF caches the ConnectionString and there is no way to update it even with a ConfigurationManager.RefreshSection(strSectionName). I have a DBContext in a different layer that is inherited so it not practical to set the connection string on each child (context.Connection.ConnectionString=). Sure I can update the constructor to use the new value when its changed but I do not want to touch a constructor and manually set ConnectionString when the framework should do that for me.
Feature: Would like to call a method in EF that refreshes the connection strings from the running config file and updates the cache.
http://social.msdn.microsoft.com/Forums/en-US/aeb91873-1f42-4f36-89cc-e43a8a9ec95f/entity-framework-611-caching-connection-string?forum=adodotnetentityframework
Comments: Hi, I've found my workaround: ``` public Model() : base(((ConnectionStringsSection) ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).GetSection("connectionStrings")).ConnectionStrings["MySqlConnection"].ConnectionString) { //This constructor works if connectionstring is changed at runtime... } ``` May it help... François