Entity Framework wizard crashes on MySQL

前端 未结 10 671
离开以前
离开以前 2020-12-16 11:50

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 specifical

相关标签:
10条回答
  • 2020-12-16 12:41

    In my case, the cause was that the version of the installed mysql connector was different from the version of referenced MySQL.Data.Entity When I referenced the same version all became alright.

    0 讨论(0)
  • 2020-12-16 12:42

    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.

    0 讨论(0)
  • 2020-12-16 12:48

    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.

    0 讨论(0)
  • 2020-12-16 12:49

    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

    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)

    0 讨论(0)
提交回复
热议问题