I need to override the DefaultDatabase value in the app.config used by DatabaseFactory.CreateDatabase() of DAAB
I have the code below, and it indicates the change succeeds, but when I reference the default database later in the code, it no longer has the changes saved by the code below. This happens whether in debug mode or as a compiled exe.
Database db = DatabaseFactory.CreateDatabase();
code to change the app.config
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var dbSettings = (DatabaseSettings)ConfigurationManager.GetSection("dataConfiguration");
string connectionString = ConfigurationManager.ConnectionStrings[dbSettings.DefaultDatabase].ConnectionString;
connectionString = connectionString.Replace("DATABASETOREPLACE", dstuff.Database).Replace("SERVERTOREPLACE", dstuff.Server);
config.ConnectionStrings.ConnectionStrings[dbSettings.DefaultDatabase].ConnectionString = connectionString;
config.Save(ConfigurationSaveMode.Modified, true);
ConfigurationManager.RefreshSection("connectionStrings");
app.config values