Missing Nodes After Adding DAAB Configuration Section

Topics: Data Access Application Block
Feb 25, 2007 at 7:51 AM
After adding the DAAB configuration section using the EntLib configuration tool I ended up with only a Connection Strings node. Other examples I see on various sites have a Database Instances node along with a Database Types node. Why might I be missing the two Database nodes?

- Rich
Feb 25, 2007 at 7:09 PM
Hey Rich,

If you don't set the DefaultDatabase Setting on the Data Access Application Block, these 2 pieces will not show up in the configuration file:

    <configSections>
        <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" />
    </configSections>
    <dataConfiguration defaultDatabase="Connection String" />

The only thing that the DAAB Configuration needs for its settings is the DefaultDatabase for the following command:

Database database = DatabaseFactory.CreateDatabase();

If you want to use the above command to work with a default database, you need to set the DefaultDatabase Setting for the DAAB using the Configuration GUI Tool. It shows up in the Property Window when you select Data Access Application Block.

As mentioned, setting the DefaultDatabase will create the above entries in your configuration class.

Regards,

Dave

__________________________

David Hayden
Microsoft MVP C#
Feb 25, 2007 at 7:34 PM
Hi Rich -

Maybe the examples you were looking at were for Enterprise Library 1.x. We changed the configuration for this block in v2 to leverage .NET's existing <connectionStrings> section, rather than use our own section. As Dave mentioned, we do have our own section for the block but it only stores the default database instance and any non-standard provider mappings.

Tom
Feb 26, 2007 at 9:24 PM
It turns out I did set the DefaultDatabase setting in the Configuration GUI Tool although I don't remember doing it (old age is catching up with me). My configuration file looks like Dave described and I successfully ran code using the DAAB.

Based on what Tom says I shouldn't expect to see the two nodes I mentioned. The whole EntLib version thing is tripping me up - I guess I have to be more careful when looking at Web sites and using Len Fenster's book.

- Rich