实体框架。您的项目引用了最新版本的实体框架错误VS2017 MYSQL 8.0.12

时间:2018-09-08 19:48:33

标签: c# mysql entity-framework-6

我有一个带有Entity Framework 6.2的Visual Studio 2017项目

尝试创建edmx文件时出现错误

  

您的项目引用了Entity Framework的最新版本;   但是,与此兼容的Entity Framework数据库提供程序   找不到您的数据连接版本

我已经经历过很多次了,但始终可以通过使用连接器安装文件夹中的dll并对app.config进行一些更改来解决此问题

但是我现在无法使其以这种方式工作。我不知道下一步该怎么做...我正在使用MYSQL 8.0.12

这是我的app.config

<configuration>
  <configSections>
    <!-- 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>
  <entityFramework>
    <defaultConnectionFactory type="MySql.Data.Entity.MySqlConnectionFactory, MySql.Data.Entity.EF6" />
    <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>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-8.0.12.0" newVersion="8.0.12.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

1 个答案:

答案 0 :(得分:0)

不确定是否仍然可以解决。但是,下面的解决方案可能对正在挣扎的人有所帮助。

是否安装了任何版本的连接器都没有关系,因为在VS 2017中不会自动引用该连接器。唯一重要的是“ MySQL for Visual Studio”。

  1. 安装“ MySQL for Visual Studio” (最好是任何最新版本1.2.8或2.0.5) 如果您在尝试安装2.0.5时遇到任何问题,请点击以下链接:https://forums.mysql.com/read.php?174,664930,664971

  2. 在您的项目中,将Nuget引用添加到“ MySQL.Data.EntityFrameWork ” (V 8.0.13或更高版本)

默认情况下,它将创建以下App.Config文件

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- 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>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="mssqllocaldb" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.EntityFramework, Version=8.0.13.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d">
      </provider></providers>
  </entityFramework>
</configuration>

然后您就可以了。它应该可以正常工作。我花了超过2天的时间,(几乎)搜索了整个google,以发现所有参考/方向/建议都指出了“ MySql.Data.Entity.EF6 ”。而“ MySql.Data.EntityFramework”可以在VS 2017上正常工作