We have an already existing console application which currently uses File based AppSettings.
So my app.config points to my actual appsettings file :
<appSettings configSource="Configs\StaticAppSettings.config"/>
And in the entire code we are accessing the configuration as such :
var value = ConfigurationManager.AppSettings["SomeKeyName"];
Going forward we want the appSettings to be in the Database.So if we want to keep the same codebase and just modify how we initialize the appsettings, is that going to be the right approach ?
We are planning to do something like this as initialization of appSettings :
ConfigurationManager.AppSettings["SomeKeyName"] = "SomeValue";
ConfigurationManager.AppSettings["SomeKeyName2"] = "SomeValue2";
Basically just create keys with the same key name as files have currently, but the Key and value come from DB instead of files.
This way our codebase still remains the same and all the appSettings are now initialized from DB instead of files.
Is this a correct approach or does it present some caveats / issues, or is there another better approach to read from DB without changing code everywhere ?