[英]EF with oracle - “The specified store provider cannot be found in the configuration, or is not valid.”
[英]MySQL Entity Framework Error - The specified store provider cannot be found in the configuration, or is not valid
我在C#中編寫了一個程序集來執行MySQL數據庫的所有數據訪問。 我在C#winform桌面應用程序中成功使用了程序集(已編譯的dll)。 但它僅適用於安裝了“MySQL Connector Net 6.4.4”的PC。
我試圖在我的asp.net網站項目中使用相同的程序集。 首先我得到一個關於缺少連接字符串的錯誤。 通過將MySQL連接字符串添加到web.config文件可以輕松解決這個問題。 我現在得到這個錯誤(下面列出的堆棧跟蹤),我已經嘗試將以下dll添加到我的bin文件夾來解決它,但它不起作用。
MySql.Data.dll
MySql.Data.Entity.dll
MySql.Web.dll
System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown.
---> System.ArgumentException: The specified store provider cannot be found in the configuration, or is not valid.
---> System.ArgumentException: Unable to find the requested .Net Framework Data Provider. It may not be installed. at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName) at System.Data.EntityClient.EntityConnection.GetFactory(String providerString)
--- End of inner exception stack trace
但它僅適用於安裝了“MySQL Connector Net 6.4.4”的PC。
這是否意味着您嘗試在未安裝提供程序的計算機上運行代碼? 在這種情況下,您還必須在配置文件中注冊提供程序,因為安裝會將其添加到machine.config,如果您沒有安裝它,則提供程序當前未注冊。
嘗試將此添加到您的web.config文件中:
<system.data>
<DbProviderFactories>
<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.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
我發現在使用獨立的.NET連接器6.6.5安裝程序時也遇到了這個問題。
要解決此問題,只需卸載獨立的.NET連接器安裝程序,然后安裝mysql-community-installer,此安裝程序允許您向MySQL添加/刪除功能,其中一個功能是具有Entity Framework支持的.NET連接器。
一旦使用此連接器,所有MySQL EF問題都將消失。
在web配置中添加此項
<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" />
</DbProviderFactories>
</system.data>
對於像我這樣通過Google解決這個老問題的人:
如果為Visual Studio 1.1.3升級到MySQL,也會出現此錯誤,這是Visual Studio 2013的第一個兼容版本,但仍然使用MySQL Connector 6.6.6,據我所知,它是最后一個版本與Entity Framework 4.3.1兼容。
我們知道我們必須盡快更新到EF5(或6),但現在這迫使我們在非常不方便的時候改變...
在卸載所有.net框架並重新安裝它們之后,我遇到了這個錯誤(我正在使用.net連接器6.4.3)。 解決方法是卸載6.4.3並安裝6.6.5
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.