簡體   English   中英

共享主機+實體框架+ MySQL =數據提供程序錯誤?

[英]Shared Hosting + Entity Framework + MySQL = Data Provider Errors?

長期聽眾,第一次來電!

我正在嘗試使用ADO.NET實體框架連接到MySQL。 (Visual Studio 2010,.NET 4.0)我創建了一個Web項目和另一個類庫項目作為我的DAL。 在我的本地機器上,我沒有問題,我也嘗試使用Medium trust運行。 我能夠按預期完全控制數據庫。

然而,當我部署到我的主機(共享,中等信任)時,我不斷收到錯誤。 我已經通過多種方式調整了web.config:我已經在連接字符串中顯式調用了程序集,我使用了通配符映射,我添加了對MySQL dll的引用等。


<connectionStrings>
    <add name="NamespaceContext" connectionString="metadata=res:// Namespace.Data.Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null/DataModel.csdl|res:// Namespace.Data.Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null/DataModel.ssdl|res:// Namespace.Data.Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null/DataModel.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=myserver;User Id=user;database=thedatabase;password=password;Persist Security Info=True&quot;" providerName="System.Data.EntityClient"/>
    <add name=" NamespaceContext " connectionString="metadata=res://*/;provider=MySql.Data.MySqlClient;provider connection string=&quot; server=myserver;User Id=user;database=thedatabase;password=password;Persist Security Info=True&quot;" providerName="System.Data.EntityClient"/>
        <add name=" NamespaceContext " connectionString="metadata=res://*/DataModel.csdl|res://*/DataModel.ssdl|res://*/DataModel.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot; server=myserver;User Id=user;database=thedatabase;password=password;Persist Security Info=True&quot;" providerName="System.Data.EntityClient" />
 </connectionStrings>

我一直得到的錯誤是:

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 --- 
at System.Data.EntityClient.EntityConnection.GetFactory(String providerString)
at System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
at System.Data.EntityClient.EntityConnection..ctor(String connectionString)
at MyNamespace.Web.Html.TestPage.EntityFrameworkTestButton_Click(Object sender, EventArgs e)

我和他們的支持人員(他們不是開發人員)談過,但是他們說安裝了MySQL連接器並且在GAC中。 我嘗試在web.config中使用DbProviderFactories部分,如下所示:

<system.data>
    <DbProviderFactories>
      <clear/>
      <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, Version=6.3.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
    </DbProviderFactories>
  </system.data>

我希望我可以控制它並在我的項目中引用提供程序。 然后我收到以下錯誤:

System.Data.MetadataException: Schema specified is not valid. 
Errors: error 0194: All artifacts loaded into an ItemCollection must have the same version. Multiple versions were encountered. 
MySql.Data.Entity.Properties.SchemaDefinition-6.0.ssdl(4,9) : error 0169: All SSDL artifacts must target the same provider. The ProviderManifestToken '5' is different from '5.0' that was encountered earlier. 
error 0194: All artifacts loaded into an ItemCollection must have the same version.

(為簡潔起見,大量相同的錯誤消息被剪斷)


我完全失去了。 我嘗試強烈簽署我的DAL項目,而不是使用DAL,只是在Web項目中創建.edmx,一切都無濟於事。 我可以發誓我在某個時候開始工作,但也許我是神志不清。

對不起牆上的文字。 任何人都可以幫助或解決一些問題?

謝謝!

我在我的應用程序中遇到了一個非常類似的問題,我在MySQL數據庫使用MySQL連接器,SQL Server數據庫使用實體框架(兩個獨立的連接,一個項目)。 MySQL.Data.Entity DLL似乎與實體框架作斗爭。 我實際上並不需要它所以我刪除它...但錯誤仍然存​​在!

最后出於絕望,我剛剛刪除了我的bin和obj文件夾並重新編譯。 問題解決了。 我想在我的文件夾中緩存或掛起了一些東西,即使在我運行干凈和重建之后。 如果其他人遇到這個問題,無論如何都要嘗試。

如果將mysql dll放在bin文件夾中會發生什么? 或者,嘗試刪除mysql DLL上的版本限制,他們可能沒有在他們的服務器上加載那個確切的版本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM