可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I am attempting to create an Entity Data Model using the wizard to reverse engineer an existing MySQL database. I get to the Choose Your Data Connection page of the wizard, select an existing MySQL connection and click Next, and the wizard crashes. Specifically, the dialog box just disappears without an error message or any trace. Every single time. Restarting VS or Windows does nothing.
I can connect to the database using Server Explorer and the same connection without problem, so I'm fairly confident it isn't a connection problem.
This is in Visual Studio 2015 with all updates installed, version 1.2.6 of MySQL for Visual Studio, EF 6.1.3, and MySql.Data and MySql.Data.Entity.EF6 versions 6.8.3.0. It is a Console application targeting the .NET Framework 4.6.1.
Google hasn't revealed anything useful yet. Another question here from yesterday is similar, but is crashing at a different point and that user can't connect using Server Explorer. So it seems to be a different situation.
There is nothing in the Windows logs that is of any help.
How can I solve this problem?
回答1:
It is caused by version mismatch.
On my system, I had MySQL Connector 6.9.6.
Issuing the command in NuGet Package Manger Console:
Install-Package MySql.Data.Entity
installs version 6.9.8 by default. Your connector must match the actual version of the NuGet Package.
You can download an updated version of the connector from: https://www.mysql.com/products/connector/
Here select the "Ado.net driver for MySQL", and download the corresponding version (in this case 6.9.8). Reopen Visual Studio and now the wizard does not crash. No reboot required.
回答2:
I had this problem today, following the tips here that it is a "version mismatch" is completely correct!
My important "discovery" is that they have renamed the package you need for EF6!
As many people here has discovered (for example "Nofi"), downgrading to match versions fixes the problem. However, instead of downgrading the new versions, swap out the Mysql.Data.Entity package for the newer MySql.Data.EntityFramework! :)
short: use MySql.Data.EntityFramework, NOT Mysql.Data.Entity
回答3:
I faced the same issue it was because I was using Mysql connector v 8.0.12 ,MySql.Data v8.0.12 and Mysql.Data.Entity v6.10.8.
The program crashes because of compatibility issues.What worked for me is I installed all three of the same version
Mysql connector v 6.10.8 and MySql.Data v6.10.8 and Mysql.Data.Entity v6.10.8.
回答4:
This keeps happening with VS2017 and the latest MySQL connector (6.10.6). Downgrading both the connector and the Nuget package to 6.9.11 works.
回答5:
Out of sheer luck and chance, I happened upon the same error.
I am using VS 2015 with Entity Framework 6 as well. The error also happened as I was attempting to create the model from the database using EF reverse engineering existing connection.
The problem is that even though the data connection exists, and you can refresh it, somehow the connection is broken. Go to the Server Explorer panel on the left, then under Data Connections find your existing connection, and instead of checking it using refresh, right click it and choose Modify Connection.
From here try testing the connection and pressing OK. You should get an error (for me it said 'Unable to connect to any of the specified MySQL hosts.')
回答6:
As I commented to Lars Meldgård, uninstalling and reinstalling version 6.9.9 of Connector/Net got me one page further in the wizard. So I'll take that as a win. But I'm really confused why this worked. I was getting the problem on two different computers, my main desktop machine and my laptop. Similar configurations in Windows 10 with everything up to date, so were both corrupted? Not likely.
So now the problem is on the Choose Your Version page of the wizard, where I'm getting the error below. But that is a different problem, which I'll tackle next.
New error on next page of wizard
回答7:
I am new to programming/.Net development. I had the same problem where the window disappears when I try and generate a entity model from MySql database.
I tried the matching versions of Nuget packages and connector but still no joy. What I did to get it working is as follows:
- I removed and then re-created the project(lucky it was a new project)
-Then generated the model from the Database
- Then I installed the Nuget packages to match the version of my connector.
I am using VS 2017 Community Edition,
Connector V6.9.9,
Nuget packages V6.8.8
Hope this helps somebody.
回答8:
Since the highest version of MySql.Data.Enetity is v6.10.8 I can find via nuget, I have downloaded the "mysql-connector-net-6.10.8.msi " so then I downgraded MySql.Data to v.6.10.8, that did trick!
回答9:
I am sharing my issue I finally resolved, as this is a real headache to catch.
I had a Role ID column in Table Role initially set to number(38,0) in SQL and created it that way, and then changed to NUMBER(10,0) and changed it.
After days of trying to resolve this, I finally right clicked the tables in the Server connection, and clicking Designer. My one table : Role, had a column ID - type number(10,0). It was linked to Table USER as RoleID. After checking the RoleID in table USER, in the designer it was showing up as Number(38,0) .
So check your foreign keys one by one... This was my issue which cost me 3 days to finally catch. My EF Dialog box also just disappeared, or would give me no tables in the EDMX file.
回答10:
<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.16.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider>
</providers>
I changed the version of MySql.Data.EntityFramework to 8.0.16 because my connector 8.0.16 and problem has vanished. this worked for me
回答11:
The mismatches seem to be on the exact version of the MySQL Connector Net. I have many projects in dev and prod with "MySQL Connector Net 8.0.13" and am not able to upgrade across the board yet. The current NuGet package was "MySQL Connector Net 8.0.15". I had to uninstall both "MySql.Data.EntityFramework 8.0.15" and "MySql.Data 8.0.15" and then force the version with command line installs to match the current version of MySQL Connector Net that I run in dev and prod:
PM> Install-Package MySql.Data -Version 8.0.13
PM> Install-Package MySql.Data.EntityFramework -Version 8.0.13
回答12:
Installing MySQL 8.0 Server with EntityFramework in Visual Studio 2019
Install MySQL Server 8.0.16
Install Complete MySQL Connector.Net x86 8.0.16
Install this custom repacked VSIX MySQL Visual Studio
If after installing MySQL Visual Studio Plugin it shows warning that failed to execute comamnd devenv /updateconfiguration, then manually execute that command in Developer Command Prompt for Visual Studio 20xx with run as administrator.
Run this command Install-Package EntityFramework in Visual Studio Nuget package manager console
Manage Nuget Packages > Search Mysql > install Mysql.Data v8.0.16
Manage Nuget Packages > Search Mysql > install Mysql.Data.Entity v6.10.8
Manage Nuget Packages > Search Mysql.Data.EntityFramework > install Mysql.Data.EntityFramework v8.0.16
Add this lines if its not automatically added after tag in Web.config and rebuild solution
</provider>-->
Even if doing all the above process some error occurs, then try uninstall nuget packages all the above added and UnInstall-Package EntityFramework uninstall visual studio plugin and connector net. Then rebuild fresh project, and add only Install-Package EntityFramework and then add references only Mysql.Data and Mysql.Data.EntityFramework for EF6 and then add the provider xml in web.config as mentioned above and remove the white space between the and tags, and rebuild project and finally try to add model.
This process is tested and working for .Net Framework 4.7.2 on Visual Studio 2019