DatabaseFactory
previously used ConnectionString
to create database. Now DatabaseProviderFactory
uses ConfigurationSource
which basically works on MVC 5 structure of web.config in XML form.
Previously we could do something like below:
string stConnName = Configuration["Data:DefaultConnection:ConnectionString"];
string stProvider = Configuration["Data:DefaultConnection:ProviderName"];
Database oDb = DatabaseFactory.CreateDatabase(stConnName);
Any idea about how to get JSON based database configurations as currently being mentioned in MVC 6 (appsettings.json) for EnterpriseLibrary 6 DatabaseProviderFactory
, in order to create generic Database, something like below, which only works with MVC 5's web.config files of XML form:
FileConfigurationSource fileConfig = new FileConfigurationSource("web.config");
DatabaseProviderFactory dbProvider = new DatabaseProviderFactory(fileConfig);
Database oDb = dbProvider.Create("DefaultConnection");