Albert Alonso
Albert Alonso

Reputation: 656

MySQL Visual Studio 2019 Integration

I switch to Visual Studio 2019 and when I tried to install MySQL for VS in order to use Entity Framework, I didn't saw the 2019 version.

I used the following link : Link to MySQL Addon and Connector

Is there any way to get the MySQL functionality in VS2019 or am I doing something wrong?

Thanks,

and as proof of concept MySQL installer

Upvotes: 9

Views: 28090

Answers (3)

ColinPM
ColinPM

Reputation: 11

I found that the MySQL installer checks a set of registry keys to detect Visual Studio (and it only goes up to Visual Studio 2017).

Sample detection key: [HKEY_CLASSES_ROOT\VisualStudio.DTE.15.0]

I faked the Visual Studio 2017 key and the installation check succeeded, and on completing the installation the MySQL tools turned up in Visual Studio 2019.

My fake registry file is just an export of the Visual Studio 2019 key already in my registry - then I changed the version number to look like the Visual Studio 2017 key that the MySQL installer was looking for. Merging the edited registry file adds the fake Visual Studio 2017 keys into the registry and leaves the existing Visual Studio 2019 keys alone.

This gets me the MySQL toolbar, and the Add Data Connection functionality. I added EF6 and the Oracle MySql.Data.EntityFramework NuGet packages to a console app and the EF stuff worked.

Here are the registry file contents - I changed the exported DTE.16.0 values in my .reg file to DTE.15.0 (i.e. the old keys that MySQL was looking for) and left the text and GUID as they were for Visual Studio 2019:


REGEDIT4

[HKEY_CLASSES_ROOT\VisualStudio.DTE.15.0]
@="Microsoft Visual Studio DTE Object"

[HKEY_CLASSES_ROOT\VisualStudio.DTE.15.0\CLSID]
@="{2E1517DA-87BF-4443-984A-D2BF18F5A908}"

Make a .reg file and merge the contents then the installer will work. Your mileage may vary so maybe check it on a VM before trusting a random Internet stranger :-) ...

Upvotes: 0

il Giovine
il Giovine

Reputation: 166

After a lot of attempts, I've found this way to make vs2019 working with MySql and EF6, at least regarding "Database 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

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

Upvotes: 11

Roger.K
Roger.K

Reputation: 221

It seems that Oracle hasn't provided official MySQL support for Visual Studio 2019 yet. You may have to wait for a new version and temporarily use Visual Studio 2017 instead.

Upvotes: 2

Related Questions