MySQL 6 与 Enterprise Library Data 5 的连接

发布于 2024-11-19 06:45:03 字数 1681 浏览 2 评论 0 原文

构建一个简单的 asp.net Web 应用程序只是为了测试(显然会在为生产站点构建任何内容之前进行重构),并且我正在尝试使用最新版本的企业库连接到 mysql 数据库,并且正在运行陷入错误: “类型 MySqlClientFactory 不包含 ConfigurationElementTypeAttribute。”

我经历了几种不同形式的尝试设置配置,并根据我发现的所有内容,将其提炼为: 在我的 web.config 中,我得到了这个:

<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>

在我的 default.aspx 页面中,我得到了这个:

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 />");
    }
}

所以,非常简单......但同样,我得到的错误是: “类型 MySqlClientFactory 不包含 ConfigurationElementTypeAttribute。”

我找不到任何关于该属性的参考... MSDN 并没有对这个属性说太多,而且它所说的内容我似乎无法与我正在做的事情联系起来...任何帮助将不胜感激。

谢谢你!

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 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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吖咩 2024-11-26 06:45:03

EntLib 不支持开箱即用的 MySql。 EntLibContrib 有一个合适的 MySql 数据提供程序。然而,发布的版本是针对 EntLib4.1 的。我可以看到 v5.0 的移植工作正在正在进行,但数据访问块没有似乎还没有完成。您可能需要自行移植。

您使用的工厂似乎没有启用 EntLib。您可以在 企业库可扩展性实践实验室

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文