Building a simple asp.net web app just to test things out (will obviously refactor before anything gets built for a production site), and I'm trying to connect to a mysql database using the latest version of the Enterprise Library, and am running into an error: "The type MySqlClientFactory does not contain the ConfigurationElementTypeAttribute."
I've gone through several different forms of trying to set up the configuration, and based on everything i've found, distilled it down to this: in my web.config i've got this:
<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<dataConfiguration defaultDatabase="MyDB">
<providerMappings>
<add name="MySql.Data.MySqlClient" databaseType="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data,Version=6.3.6,Culture=neutral,PublicKeyToken=c5687fc88969c44d"/>
</providerMappings>
</dataConfiguration>
<connectionStrings>
<add name="MyDB" connectionString="Server=localhost;Database=MyDB;Uid=root;Pwd=****;"
providerName="MySql.Data.MySqlClient"/>
</connectionStrings>
and in my default.aspx page I've got this:
protected void Page_Load(object sender, EventArgs e)
{
string sql = "select * from users";
Database db = EnterpriseLibraryContainer.Current.GetInstance<Database>("MyDB");
var reader = db.ExecuteReader(CommandType.Text, sql);
while (reader.NextResult())
{
Response.Write(reader["userName"] + "<br />");
}
}
so, very simple... but again, the error i'm getting is: "The type MySqlClientFactory does not contain the开发者_JAVA百科 ConfigurationElementTypeAttribute."
and I can't find any reference to that... the MSDN doesn't say much about that attribute, and what it does say I can't seem to relate to what i'm doing... any help would be appreciated.
Thank you!
EntLib doesn't support MySql out of the box. EntLibContrib has a proper MySql Data Provider. The one released, however, targets EntLib4.1. I can see a porting effort to v5.0 is under way but the Data Access block doesn’t appear to be done yet. You may need to port yourself.
The factory you are using doesn't seem to be EntLib-enabled. You can find a good treatment of the ConfigurationElementTypeAttribute as well as other guidance on how to extend EntLib in the Enterprise Library Extensibility Hands-on Labs.
精彩评论