因為要為一個舊的應用寫擴展,用Code First模式寫,需要寫很多代碼,就想用EF6+MySql DB First模式。搗鼓了一晚上。最終找到解決方案:
1) Remove mysql for visualstudio
2) Remove mysql connector net
3) Install mysql for visualstudio 2.0.5
4) install mysql connector net 6.10.8
5) Create a new C# project using framework 4.5.2
6) Via Nuget, add Microsoft Entity Framework 6.2.0
7) Via Nuget, add MySql.Data.Entity 6.10.8
這里通過命令安裝:Install-Package MySql.Data.Entity -Version 6.10.8
8) Open App.config. There are errors in the row:
<provider invariantName="MySql.Data.MySqlClient" ...
add the missing '/' at the end and delete '</provider>'
9) Build the solution
Now add a new ADO.Net Entity Data Model and you should be able to work with your mysql database
參考:https://stackoverflow.com/questions/55642848/mysql-visual-studio-2019-integration