Entity Framework wizard crashes on MySQL

11,899

Solution 1

It has been answered in another thread, the typical crash reason is the mismatched versions of MySQL connector and MySQL.Data.Entity.

And most likely reason for you to get the wrong version is because of the package name changed from MySQL.Data.Entity to MySql.Data.EntityFramework.

I was spending a lot of time on trying the answers in the thread, so just FYI.

Solution 2

I have no idea why this works but I went in to my NuGet Package Manager and removed the MySql.Data.Entity (also checked dependencies which removed MySql.Data). I went into my .edmx and ran the 'Update model from database...' and everything worked.

(Note: This also removed my entity framework so I had to add that back in using the NuGet Manager)

W...T...F?

Maybe others can confirm this...

Solution 3

When you look around this seems to be a common problem. I know this way along the trail but late is better then never.

I eventually removed and reinstalled visual studio 2015 and mysql and then started from scratch. I then ensured that I walked through the process bringing in only what was needed.

  1. Using nuget install MySql.Data 6.9.9 and MySql.Data.Entity 6.9.9. Nothing else.
  2. Nuget does not change the web config correctly so you need to change it as below.

Before

<entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
         <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
     </providers>
</entityFramework>

After

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

This fixed it for me. I am not sure that you need do the reinstall, but for sure you need do step 2.

Good luck.

Solution 4

For anyone who's still encountering this issue here are the versions that I had to install to get it working:

MySQL for Visual Studio: 2.0.5 (note that at the time of posting the latest General Availability release is 1.2.9 - you'll need to go to the Development Releases tab to get version 2.0.5 - https://dev.mysql.com/downloads/windows/visualstudio/)

MySQL Connector/NET: 6.9.11 (https://downloads.mysql.com/archives/c-net/)

MySQL.Data NuGet package: 6.9.11 (Install-Package MySql.Data -Version 6.9.11)

MySQL.Data.Entity NuGet package: 6.9.11 (Install-Package MySql.Data.Entity -Version 6.9.11)

(Note that I didn't have to adjust the config file.)

Hope it helps.

Solution 5

The problem is the compatibility of MySQL, Visual Studio, connector and MySQL for Visual Studio.


  1. Close Visual Studio.
  2. You need to uninstall MySQL Connector and MySQL for Visual Studio. (Restart your computer)
  3. If you have two versions of the visual studio it will work only in one of them. So choose which you want.
  4. Install the correct versions. (Restart your computer).

    • Visual Studio 2019 (Community, Professional, and Enterprise) - MySQL for Visual Studio 1.2.9 with Connector/NET 8.0.14
    • Visual Studio 2017 (Community, Professional, and Enterprise): -MySQL for Visual Studio 1.2.7 with Connector/NET 6.9.9
    • Visual Studio 2015 (Community, Professional, and Enterprise): -MySQL for Visual Studio 1.2.7 or 2.0.2 with Connector/NET 6.9.8
  5. Open VS and build your project then try to update your entities

enter image description here Actually I'm using VS professional 2017 with this nuggets MySql.Data 6.9.9 and MySql.Data.Entity 6.9.9(MySQL for Visual Studio 1.2.7 with Connector/NET 6.9.9)

Share:
11,899

Related videos on Youtube

usr-local-ΕΨΗΕΛΩΝ
Author by

usr-local-ΕΨΗΕΛΩΝ

Chuck Norris is the only one who can type my name on a keyboard by using my teeth as keys, courtesy of a roundhouse kick in my mouth

Updated on June 07, 2022

Comments

  • usr-local-ΕΨΗΕΛΩΝ
    usr-local-ΕΨΗΕΛΩΝ almost 2 years

    My question is similar to this one but the crash happens later. I must interoperate an EF database-first model between SQL Server and MySQL. More specifically, my application had plain SQL queries fired to either SQL Server or MySQL according to connection string and configuration setting (DB_TYPE=MYSQL, etc.), having both databases with same structure and maintained together, so that each modification to one's schema was reapplied to the other.

    Now I added EF support to the application using SQL Server database-first model. I must now let the application run on MySQL too. In order to verify that the old developer didn't leave something disaligned between the two DBMSes, I tried to Update model against database* and this time I selected the MySQL connection to my development database on localhost.

    After I click Next on the screen below, it will simply crash and return to EDMX editor

    Data Model wizard

    I need to go ahead with the project, I'm stuck on this since a while.

    Here is my Web.config fragment:

    <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
          <parameters>
            <parameter value="v11.0" />
          </parameters>
        </defaultConnectionFactory>
        <providers>
          <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
          <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
        </providers>
      </entityFramework>
      <system.data>
        <DbProviderFactories>
          <remove invariant="MySql.Data.MySqlClient" />
          <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
        </DbProviderFactories>
      </system.data>
    

    How can I solve my problem? I reinstalled MySQL tools for Visual Studio but didn't help.

    *I use a localized version of Visual Studio, so I don't know the original English for all commands

    • kbrimington
      kbrimington about 9 years
      I face a similar issue. Did you ever find a resolution?
    • bubi
      bubi almost 9 years
      I know that this is not an answer but Database First is not a good approach to access different DBMS types. In EF7 is not supported anymore, EF providers are very hard to write and often there are issues like your. The best approach is to generate classes from database with a tool like CodeSmith or something similar then go on with a Code First approach.
    • Norbert van Nobelen
      Norbert van Nobelen almost 9 years
      Any errors in any log?
    • Kobi
      Kobi almost 9 years
    • usr-local-ΕΨΗΕΛΩΝ
      usr-local-ΕΨΗΕΛΩΝ almost 9 years
      Yes, related. But at least I can complete one more step
    • Kobi
      Kobi almost 9 years
      Oh, sorry. I didn't see you already linked to it. So you didn't find a solution?
    • Bradley Grainger
      Bradley Grainger almost 6 years
    • coolblue2000
      coolblue2000 over 5 years
      @ bubi Sorry but I totally disagree. Code first is a terrible solution for large projects and relational dbs and can generate horrible table sets that need hundreds of joins in queries. Database First allows the database to be treated as a first class citizen with all the care and attention it needs to perform well. I have worked on many code first projects and all have had major issues.
    • Rickey
      Rickey over 5 years
      This link provided a solution for me: forums.mysql.com/read.php?174,667307,667319#msg-667319
  • usr-local-ΕΨΗΕΛΩΝ
    usr-local-ΕΨΗΕΛΩΝ over 8 years
    Could you reproduce (e.g. checkout an earlier version from source code...?) and confirm which packages to remove? So we can reproduce on our side and confirm. Actually yours looks more like a comment of a confused user. I would suggest taking a short breath and investigate. By the way MySQL packages have been upgraded since question day zero
  • Ian Newland
    Ian Newland over 8 years
    Yeah I've actually been able to reproduce this on a daily basis. The MySql connection stops working randomly, and in order to fix this I have to uninstall and reinstall the packages using NuGet. If you know of any error logs I can check I'd love to find out what is causing this.
  • usr-local-ΕΨΗΕΛΩΝ
    usr-local-ΕΨΗΕΛΩΝ over 7 years
    Worth to give a try
  • Karishma
    Karishma about 6 years
    This was the only solution I could find spending hours for this particular problem. Amazing! Thank you so much! You are a life saver.
  • Literate Corvette
    Literate Corvette about 3 years
    I'm starting to understand the guy who applied to a software job and got hired, fixed a bug that had been frustrating him as a user, then quit.
  • Literate Corvette
    Literate Corvette about 3 years
    Some of these versions no longer show up in the NuGet Package Manager interface but still work if you put the entry into the command-line console. As well as Install-Package MySql.Web -Version 6.9.11 If you need that.
  • BrownPony
    BrownPony about 3 years
    @LiterateCorvette True that. I have just got back into it and found this link. c-sharpcorner.com/article/… Works like cool breeze on a hot summer day
  • 4b0
    4b0 about 3 years
    BrownPony, a link to a solution is welcome, but please ensure your answer is useful without it: add context around the link so your fellow users will have some idea what it is and why it is there, then quote the most relevant part of the page you are linking to in case the target page is unavailable. Answers that are little more than a link may be deleted.
  • BrownPony
    BrownPony almost 3 years
    @Shree I added what I believe is the essence of the article. It is too long to post. If you think it should be deleted then I am okay with that.
  • Kniganapolke
    Kniganapolke over 2 years
    Thank you. I installed a newer version of MySql.Data package and replaced MySql.Data.Entity with MySql.Data.EntityFramework (of the same version as MySql.Data) and it helped.