Today, I found on the Internet how to integrate Microsoft Enterprise Library 5.0 into the MySQL database, and found only the extension module of entlib 4.1,
Http://entlibcontrib.codeplex.com/, according to the above instructions after the preparation is still not successful.
So I had to manually modify it to support entlib 5.0.
Modified project: MySqlDAAB.rar
MySql. Data. dll: MySql. Data. dll
1. Modify the MySqlDatabaseAssembler. cs file.
Public class MySqlDatabaseData: DatabaseData
{
# Region Public Methods
Public MySqlDatabaseData (ConnectionStringSettings connectionStringSettings, IConfigurationSource configurationSource)
: Base (connectionStringSettings, configurationSource)
{
}
# Endregion
Public override System. Collections. Generic. IEnumerable <Microsoft. Practices. EnterpriseLibrary. Common. Configuration. ContainerModel. TypeRegistration> GetRegistrations ()
{
Yield return new TypeRegistration <Database> (
() => New MySqlDatabase (
ConnectionString,
Container. Resolved <IDataInstrumentationProvider> (Name ))){
Name = Name,
Lifetime = TypeRegistrationLifetime. Transient
};
}
}
2. Modify the constructor in the MySqlDatabase. cs file and add the configuration attribute to the MySqlDatabase class.
[ConfigurationElementType (typeof (MySqlDatabaseData)]
Public class MySqlDatabase: Database
{
Public MySQLDatabase (string connectionstring)
: Base (connectionstring, mysqlclientfactory. instance)
{
}
Public MySQLDatabase (string connectionstring, idatainstrumentationprovider instrumentationprovider)
: Base (connectionstring, mysqlclientfactory. instance, instrumentationprovider)
{
}
3. Compile the MySqlDAAB Project
4. Reference The MySqlDAAB project in the project
5. The configuration file is as follows:
<Configsections>
<Section name = "dataconfiguration"
Type = "Microsoft. Practices. enterpriselibrary. Data. configuration. databasesettings,
Microsoft. Practices. enterpriselibrary. Data "/>
</Configsections>
<Dataconfiguration>
<Providermappings>
<Add name = "mysql. Data. mysqlclient"
Databasetype = "entlibcontrib. Data. MySQL. MySQLDatabase, mysqldaab"/>
</Providermappings>
</Dataconfiguration>
<System. Data>
<Dbproviderfactories>
<Add
Name = "My SQL data provider factory"
Invariant = "mysql. Data. mysqlclient"
Description = ""
Type = "mysql. Data. mysqlclient. mysqlclientfactory"/>
</Dbproviderfactories>
</System. Data>
<Connectionstrings>
<Add name = "testdb_mysql"
Connectionstring = "Server = 127.0.0.1; database = test; user id = root; Password = ***; persist Security info = true ;"
Providername = "mysql. Data. mysqlclient"/>
</Connectionstrings>
In this way, you can use the MySQL database.