【发布时间】:2014-03-07 23:33:23
【问题描述】:
MySql 连接器(6.8.3) 和 EF6 有一个奇怪的问题。我正在开发一个 WebApi 项目,我在其中使用 MySql 和 EF6 和数据库优先方法。一切正常[甚至部署在其中一台测试服务器上],直到我将连接字符串中的数据库从“测试”数据库更改为“生产”数据库[只是数据库名称]并更新了模型[只是看到没有任何损坏! ]。之后,它无法连接到数据库。所以,我改回了连接字符串并重建了解决方案,然后我收到了一堆“映射”警告。我删除了模型并尝试从数据库中再次创建模型。现在,我收到以下消息
您的项目引用了最新版本的实体框架; 但是,与此兼容的实体框架数据库提供程序 无法为您的数据连接找到版本。退出此向导, 安装兼容的提供程序,并在之前重建您的项目 执行此操作
这是配置文件
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<system.data>
<DbProviderFactories>
<clear/>
<remove invariant="MySql.Data.MySqlClient"/>
<add name="MySql.Data.MySqlClient" description="ADO.Net driver for MySQL" invariant="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data,Version=6.8.3.0, Culture=neutral,PublicKeyToken=c5687fc88969c44d"/>
</DbProviderFactories>
</system.data>
<entityFramework codeConfigurationType="MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6">
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
我尝试从 Nuget 重新安装连接器和 EF,但没有任何改变。谁能告诉我这是怎么回事?
谢谢
【问题讨论】:
-
我还在努力解决这个问题!感谢任何帮助或建议?
-
确保您的项目包含对 MySQL EF 提供程序的引用 - 该消息表明 EF 设计器找不到可用于与数据库通信的提供程序。一旦您的项目中有提供程序,请确保在启动向导之前构建项目。这一步非常重要。
-
@Pawel 在我更改连接字符串之前它运行良好。除了连接,我什么都没改变!!
-
@Kuzgun 可能是。但我不确定!
标签: mysql ado.net entity-framework-6 ef-database-first