在Visual Studio中制作Entity Framework 6模型会关闭向导并断开MYSQL连接数据库的连接

时间:2018-08-28 13:21:09

标签: c# mysql entity-framework

我试图将使用实体框架6的ADO.Net实体数据模型添加到Net.Framework类库中,但是当我进入第3步时,当您选择框架版本时,它将立即关闭向导,并关闭与我的连接MYSQL数据库This is what it shows before it closes自动断开连接。

我的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>
  <connectionStrings>
    <add name="MyContext" providerName="MySql.Data.MySqlClient"
        connectionString="server=localhost;port=3306;database=mycontext;uid=root;password=********"/>
</connectionStrings>
  <entityFramework>
    <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>
  <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="Google.Protobuf" publicKeyToken="a7d26565bac4d604" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.6.1.0" newVersion="3.6.1.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

我已经使用NuGet安装了安装在类库中的Entity Framework 6.20,Mysql.Data 8.0.12,MySql.Data.Entity 6.10.8,Google.Protobuf 3.6.1,并将其添加为引用。而且我已经重新安装,更新,使用了MYSQL Installer,但运气不佳。

我也有一个Net.Core Web API应用程序作为第一个项目,但是我知道Net.core不支持Framework 6,仅支持实体核心,因此您必须添加net.framework类库并添加它们。库中的参考。

请注意,我(参见图片)与“找不到实体框架数据库提供程序”具有相同的错误,但没有该错误,框架版本会自动选择,但关闭。谢谢。

编辑

对于那些遇到此问题的人,我有一种解决方法,我必须从安装程序中卸载Net Connector,然后分别下载Net Connector 6.10.8,一切正常。

2 个答案:

答案 0 :(得分:0)

这是MySQL VS集成中的一个已知错误:bug 91195

其他一些用户发布了在该链接上找到的解决方法。您可能需要等待Oracle发布不会崩溃的VS插件。

答案 1 :(得分:0)

似乎可以使用以下版本:连接器6.10.8和MySQL for VS 1.2.8