简体   繁体   English

Visual Studio 2017和MySQL EntityFramework

[英]Visual Studio 2017 and MySQL EntityFramework

When adding a new ADO.NET Entity Data Model > EF Designer From database > New Connection > Change Connection I do not see MySQL as an option; 当添加新的ADO.NET Entity Data Model > EF Designer From database > New Connection > Change Connection我没有选择MySQL。

在此处输入图片说明

I have installed NuGet package MySQL.Data.Entity (as well as the required MySql.Data and Google.Protobuf). 我已经安装了NuGet包MySQL.Data.Entity(以及所需的MySql.Data和Google.Protobuf)。

Also when I add the package MySQL.Data.Entity, my existing MS SQL entities returns this error message; 同样,当我添加包MySQL.Data.Entity时,我现有的MS SQL实体会返回此错误消息。

System.TypeLoadException: 'Inheritance security rules violated by type: 'MySql.Data.MySqlClient.MySqlProviderServices'. System.TypeLoadException:'类型违反了继承安全性规则:'MySql.Data.MySqlClient.MySqlProviderServices'。 Derived types must either match the security accessibility of the base type or be less accessible.' 派生类型必须与基本类型的安全可访问性匹配,或者不可访问。

Yet in the App.config it is still pointing to MS SQL; 然而,在App.config中,它仍然指向MS SQL。

<add name="MyDBEntities" connectionString="metadata=res://*/MyEntity.csdl|res://*/MyEntity.ssdl|res://*/MyEntity.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=MSSQLSERVER;initial catalog=MyDB;persist security info=True;user id=sa;password=MyPassword;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

If I remove the NuGet package MySQL.Data.Entity and change nothing it works correctly. 如果我删除NuGet包MySQL.Data.Entity并进行任何更改,它将正常工作。

I solved just today the same error uninstalling all MySQL and re-installing (in the same order): 今天,我解决了相同的错误,即卸载所有MySQL并重新安装(以相同顺序):

And, in the VS project, installing with the Nuget package manager: 并且,在VS项目中,使用Nuget软件包管理器进行安装:

  • 1.- Entity Framework v.6.0.0 1.-实体框架v.6.0.0
  • 2.- MySql.Data and MySql.Data.Entity v.6.8.8 2.- MySql.Data和MySql.Data.Entity v.6.8.8

I had been proving another versions and never the MySQL Data Source had seen until select this combination. 我一直在证明另一个版本,直到选择此组合之前,从未见过MySQL数据源。 I hope it's work for you. 希望对您有用。 Regards. 问候。

NOTE: I have Visual Studio 2017. 注意:我有Visual Studio 2017。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM