I am use Database MySQL in ASP.NET c# application.When I use simple Steps for connect the MySQL database and create ADO.NET connections working fine. But I want to use Microsoft Enterprise Library for my application.I added Reference given below
- Microsoft.Practices.EnterpriseLibrary.Common
- Microsoft.Practices.EnterpriseLibrary.Data
- Microsoft.Practices.EnterpriseLibrary.Data.S
- MySql.Data
- MySql.Web
Below is my web.comfig code
<system.data>
<DbProviderFactories>
<remove invariant="MySql.Data.MySqlClient" />
<add name="MySQL Data Provider"
invariant="MySql.Data.MySqlClient"
description=".Net Framework Data Provider for MySQL"
type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.4.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
<dataConfiguration defaultDatabase="db1"></dataConfiguration>
<connectionStrings>
<add name="constr" connectionString="Server=localhost;Database=db1;user id=test;persistsecurityinfo=True;" providerName="MySql.Data.MySqlClient;"/>
</connectionStrings>
<configuration>
<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" />
</configSections>
and when I use in code by below code
if (_connectionMode == DatabaseConnectionMode.UseConnectionStringName)
{
_Database = new DatabaseProviderFactory().Create(_dbConnectionString) as Database;
}
here throw the below error
The requested database db1does not have a valid ADO.NET provider name set in the connection string.
Give me proper solution with reason why this happening.