A Bug of Data Block Configuration??????

Topics: Data Access Application Block
Nov 28, 2007 at 6:10 AM

If I set all enterprise library configurations to a single file :

in <web.config>

<configSections>
<section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</configSections>

<connectionStrings>
<add
name="DataAccessQuickStart"
providerName="System.Data.SqlClient"
connectionString="server=(local)\SQLEXPRESS;database=EntLibQuickStarts;Integrated Security=true" />
</connectionStrings>


<enterpriseLibrary.ConfigurationSource selectedSource="File Configuration Source">
<sources>
<add name="File Configuration Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" filePath="entlib.config"/>
</sources>
</enterpriseLibrary.ConfigurationSource>



then in entlib.config:

<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data" />
</configSections >
<dataConfiguration defaultDatabase="DataAccessQuickStart"/>





If I deploy such a configuration, and in my code I write:

Database db = DatabaseFactory.CreateDatabase();

I will get this exception
The requested database DataAccessQuickStart is not defined in configuration

If I use SqlDatabase to directly create an sql instance ( SqlDatabase db = new SqlDatabase( "DataAccessQuickStart") )
Everything goes well.

Why does it happen?? Is it an EnterpriseLibrary's bug???

Nov 28, 2007 at 3:39 PM
ConnectionString Settings should be along with your DataConfiguration Settings.