2011-07-06 94 views
2

構建一個簡單的asp.net web應用程序只是爲了測試事情(顯然將重構生產站點的任何東西之前),我試圖連接到一個MySQL數據庫使用最新版本的企業庫,並且遇到以下錯誤: 「MySqlClientFactory類型不包含ConfigurationElementTypeAttribute。」MySQL 6連接企業庫數據5

我已經通過幾種不同形式的試圖建立的配置了,並且基於一切我已經找到了,蒸餾下來到這一點: 在我的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並沒有多說這個屬性,它說了什麼,我似乎無法涉及我在做什麼...任何幫助將不勝感激。

謝謝!

回答

1

EntLib不支持MySql開箱即用。 EntLibContrib有一個合適的MySql Data Provider。但是,發佈的目標是EntLib4.1。我可以看到v5.0的移植工作是under way,但數據訪問模塊似乎尚未完成。你可能需要自己移植。

您正在使用的工廠似乎不支持EntLib。你可以找到ConfigurationElementTypeAttribute對如何在Enterprise Library Extensibility Hands-on Labs延長EntLib良好的治療以及其他指導。

+0

謝謝,我也試試這個端口,比它解決它創造了更多的問題,但我沒有時間去完成實驗室的,所以當我這樣做,這可能會有所幫助。 –