Instantiating Database object using external connection strings

Topics: Data Access Application Block
Apr 29, 2010 at 4:18 PM

I would like to instantiate a Database object using Enterprise Library (v. 4.1 or v. 5.0) such that I can utilize an external source for my connection strings rather than storing them in a configuration file.  In our case, we store all of our database connection strings in a SQL Server or Oracle database which acts as a configuration database for all of our other databases.

I know that I can directly instantiate the correct database provider using the DbProviderFactories.GetFactory method directly from the System.Data.Common namespace, but then I lose all of the advantages of utilizing the Enterprise Library for my common data access operations.

Is there a way to accomplish the same thing using Enterprise Library and passing either a connection string or a database provider in order to obtain a handle to the correct ADO.Net Enterprise Library database provider?  Currently, it seems that DatabaseFactory.CreateDatabase only has 2 overloads and both of them require connectionString information stored in a configuration file.


Apr 30, 2010 at 2:11 AM

Answered in


Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.