MySQL and MVC Entity Framework in VS 2017 Not Working

Viewed 8938

I am trying to start an MVC EF Visual Studio 2017 project. I have my Data Connection all set up with MySQL on my local instance but when I go to create an ADO.net Data Model I get the error seen in the picture:

enter image description here

There was another article here: Can't use a MySQL connection for entity framework 6 that covered VS 2012 and 2013 but not 2017. Here is the MySQL documentation that says what versions work with 2017: https://dev.mysql.com/doc/visual-studio/en/visual-studio-install.html

I am using:

MySQL Connector Net 6.9.9 | MySQL for Visual Studio 1.2.7 | MySQL Server 5.7

MySQL.Data 6.9.9 | MySQL.Data.Entity 6.9.9 | Entity Framework 6.1.3

All of which are listed as tested and working by MySQL. I just installed all new everything today so there are no outstanding old versions. I triple checked ;)

Connection string:

<connectionStrings> <add name="MySQL" connectionString="server=localhost;port=3306;user id=root;password=password;database=localdb" providerName="MySql.Data.MySqlClient" /> </connectionStrings>


Edit

I have found this article https://dev.mysql.com/doc/connector-net/en/connector-net-entityframework60.html that talks about setting up the connection but now instead of that error, the dialog box just goes away as soon as I hit 'Next'.


Is this just me doing something incorrectly or a broken MySQL connector?

Thanks in advance for any advice!

4 Answers

@James Wilkins Thanks for the detailed answer, I've to add, sometime when you are adding Mysql.data or MySQL.data.entity the assembly version doesn't match the assemblies installed by MySqlConnector/Net, as we often download the latest version from Nuget, this cause this issue again, so what I did and fixed the issue, I copied the dll (Mysql.data, MySQL.data.entity and web) from

C:\Program Files (x86)\MySQL\MySQL Connector Net 6.9.9\Assemblies\v4.5

to my application bin/debug folder and reference these instead of downloading from Nugets. This fixed my issues. You may also need to update the assembly version in app.config or web.config and packages.config file as well.

<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.10.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"> 

To

<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d">

And update the version for the entries here in packages.config

  <package id="MySql.Data" version="6.9.9" targetFramework="net452" />
  <package id="MySql.Data.Entity" version="6.9.9" targetFramework="net452" />
  <package id="MySql.Web" version="6.9.9" targetFramework="net452" />
Related