Connect Entity Framework with MYSQL in VS2019

强颜欢笑 提交于 2020-12-12 11:35:06

问题


I just installed Visual Studio 2019 and I´m trying to add a database with an ADO.NET entity model, but the wizard crashes in this step...

Select Entity Framework Version

I have Visual Studio Community 2019 v16.4.5
Installed MySQL for Visual Studio 1.2.9
Installed MySQL connector net 8.0.19

I added the references to my project
MySQL.data
MySQL.data.EntityFramework for EF6
MySQL.web

all version 8.0.19, same as the connector

I also tried adding from nuget packages
EntityFramework
MySqlData
MySql.Data.Entity
MySql.Web

and added this to web.config

<entityFramework>
<providers>
<provider invariantName="MySql.Data.MySqlClient"
type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
</providers>
</entityFramework>

and tried everything I've read but it still doesnt work, it just crashes after that or it gives me this error

Your Project references the latest version of Entity Framework

Can someone please help? Am I adding worng versions?


回答1:


Okay, after many days I finally could add my data base. I've seen comments of others saying the ADO wizard crashes so here's what I did...

With VS Community 2019 Installed latest versions of
MySQL connector net
MySQL for Visual Studio

After created my project I went to admin NuGet packages and installed latest version of Entity Framework

Then in references added
MySql.Data.EntityFramework for EF6

Then added this to my web.config

<entityFramework>
    <providers>
     <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.EntityFramework" />
    </providers>
  </entityFramework>

Recompile And the wizard works just fine!

It was very important to write MySql.Data.EntityFramework and not .EF6




回答2:


You can try pomelo.EntityFrameworkCore.Mysql provider



来源:https://stackoverflow.com/questions/60386441/connect-entity-framework-with-mysql-in-vs2019

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!