DAAB - How to use custom providers with EntLib5.0

Topics: Data Access Application Block
Apr 15, 2011 at 12:45 AM

The following discussion thread mentions that the provider name attribute should be 'System.Data.OleDb':

http://entlib.codeplex.com/discussions/232371?ProjectName=entlib

I would like to use a cutom provider so what is the procedure to add a custom provider to the configuration. When I use a custom provider and add a provider mapping for that provider in the config file I get the following error on the DatabaseFactory.CreateDatabase("DBName") call:

Error Message: The type <db provider class name> does not contain the ConfigurationElementTypeAttribute.

This code worked fine with EntLib 4.1. So, What is the correct way to use custom provider with EntLib 5?

Thank you,

Ramesh

Apr 15, 2011 at 3:16 AM

Hi,

May I ask what database you are using here? Yes, creating a custom provider in EntLib 5 has changed and it now requires the ConfigurationElementType attribute. If you want to, you can send me your email so I can send you the sample code on how to create a custom database provider.

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Apr 15, 2011 at 5:50 AM

Hi Noel,

The database is SQL Server. The following configuration was used to set custom provider:

<dataConfiguration defaultDatabase="CamstarDB">

<providerMappings>

<add databaseType="DDTek.EnterpriseLibrary.Data.SQLServer.SQLServerDatabase, DDTek.EnterpriseLibrary.Data.SQLServer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"

name="System.Data.SqlClient" />

</providerMappings>

</dataConfiguration>

<connectionStrings>

<add name="CamstarDB" connectionString="NA" providerName="System.Data.SqlClient" />

</connectionStrings>

The following error is returned with this configuration:

"The type SQLServerDatabase does not contain the ConfigurationElementTypeAttribute."

Please send me the samples to setup custom providers and also the required configuration.

Thank you,

Ramesh

From: AvanadeSupport [email removed]
Sent: Thursday, April 14, 2011 8:16 PM
To: Ramesh Nagamalli
Subject: Re: DAAB - How to use custom providers with EntLib5.0 [entlib:253976]

From: AvanadeSupport

Hi,

May I ask what database you are using here? Yes, creating a custom provider in EntLib 5 has changed and it now requires the ConfigurationElementType attribute. If you want to, you can send me your email so I can send you the sample code on how to create a custom database provider.

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Apr 15, 2011 at 6:19 AM

Hi Noel,

I have another question. In EntLib 4.1, there was an interface ‘IDatabaseAssembler’ which we used to construct the connection string dynamically since we don’t put that in the config file. Since this interface is no longer part of EntLib 5 how can we achieve this now?

Thank you,

Ramesh

704 973 6975

From: Ramesh Nagamalli
Sent: Thursday, April 14, 2011 10:50 PM
To: 'entlib@discussions.codeplex.com'; 'entlib.support@avanade.com'
Subject: RE: DAAB - How to use custom providers with EntLib5.0 [entlib:253976]

Hi Noel,

The database is SQL Server. The following configuration was used to set custom provider:

<dataConfiguration defaultDatabase="CamstarDB">

<providerMappings>

<add databaseType="DDTek.EnterpriseLibrary.Data.SQLServer.SQLServerDatabase, DDTek.EnterpriseLibrary.Data.SQLServer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"

name="System.Data.SqlClient" />

</providerMappings>

</dataConfiguration>

<connectionStrings>

<add name="CamstarDB" connectionString="NA" providerName="System.Data.SqlClient" />

</connectionStrings>

The following error is returned with this configuration:

"The type SQLServerDatabase does not contain the ConfigurationElementTypeAttribute."

Please send me the samples to setup custom providers and also the required configuration.

Thank you,

Ramesh

From: AvanadeSupport [email removed]
Sent: Thursday, April 14, 2011 8:16 PM
To: Ramesh Nagamalli
Subject: Re: DAAB - How to use custom providers with EntLib5.0 [entlib:253976]

From: AvanadeSupport

Hi,

May I ask what database you are using here? Yes, creating a custom provider in EntLib 5 has changed and it now requires the ConfigurationElementType attribute. If you want to, you can send me your email so I can send you the sample code on how to create a custom database provider.

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Apr 15, 2011 at 7:14 AM

I already send the sample project. The only way I can think of right now is to instantiate the SqlDatabase directly and specify the connectionstring there.

Database db = new Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase(connectionString);

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Apr 15, 2011 at 7:24 AM

Hi Noel,

I looked at the sample code you sent me. What is the purpose of ‘DatabaseData’ class? Could we add an override for the ‘ConnectionString’ property in the class ‘ExtendedSqlDatabaseData’ to construct the connection string dynamically. Is this object used in the process of creating a connection?

Thank you,

Ramesh

From: AvanadeSupport [email removed]
Sent: Friday, April 15, 2011 12:15 AM
To: Ramesh Nagamalli
Subject: Re: DAAB - How to use custom providers with EntLib5.0 [entlib:253976]

From: AvanadeSupport

I already send the sample project. The only way I can think of right now is to instantiate the SqlDatabase directly and specify the connectionstring there.

Database db = new Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase(connectionString);

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Apr 15, 2011 at 9:31 AM
Edited Apr 15, 2011 at 9:32 AM

The DatabaseData class provides configuration support for your custom provider. I don't think you can override the connectionstring here. I recommend you to read the documentation of Creating Customs Providers for Enterprise Library which can be found here. Hope this helps :)

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Apr 15, 2011 at 5:37 PM

Thank you Noel.

Thank you,

Ramesh

From: AvanadeSupport [email removed]
Sent: Friday, April 15, 2011 2:31 AM
To: Ramesh Nagamalli
Subject: Re: DAAB - How to use custom providers with EntLib5.0 [entlib:253976]

From: AvanadeSupport

The DatabaseData class provides configuration support for your custom provider. I recommend you to read the documentation of Creating Customs Providers for Enterprise Library which can be found here. Hope this helps :)

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com