[英]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="server=myserver;User Id=user;database=thedatabase;password=password;Persist Security Info=True"" providerName="System.Data.EntityClient"/>
<add name=" NamespaceContext " connectionString="metadata=res://*/;provider=MySql.Data.MySqlClient;provider connection string=" server=myserver;User Id=user;database=thedatabase;password=password;Persist Security Info=True"" 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=" server=myserver;User Id=user;database=thedatabase;password=password;Persist Security Info=True"" 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.