【发布时间】:2011-05-17 15:43:39
【问题描述】:
长期聆听者,第一次来电者!
我正在尝试使用 ADO.NET 实体框架连接到 MySQL。 (Visual Studio 2010,.NET 4.0)我创建了一个 Web 项目和另一个类库项目作为我的 DAL。在我的本地机器上,我没有问题,我也尝试过使用中等信任运行。我能够按预期完全控制数据库。
但是,当我部署到我的主机(共享、中等信任)时,我不断收到错误消息。我已经通过多种方式调整了我的 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 frameworks hosting entity shared