MySql Connector with EF 6

I have a strange problem with MySql Connector (6.8.3) and EF6. I was working on a WebApi project where I use MySql and EF6 with a basic Database approach. Everything worked fine [even deployed to one of the test servers] until I changed the database from the Test database to the Production database [only the database name] in the connection string and updated the model [just to see that nothing is broken! ]. After that, he was unable to connect to the database. So, I changed the connection string and rebuilt the solution, then I got a bunch of “Mapping” warnings. I deleted the model and tried again to create the model from the database. Now I get the following message

Your project references the latest version of the Entity Framework; however, a compatible database provider Entity Framework could not find a data connection for you. Exit this wizard, install a compatible provider, and rebuild the project before completing this step.

Here is the configuration file

    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />

  </configSections>
  <system.data>
    <DbProviderFactories>
      <clear/>
      <remove invariant="MySql.Data.MySqlClient"/>
      <add name="MySql.Data.MySqlClient" description="ADO.Net driver for MySQL" invariant="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data,Version=6.8.3.0, Culture=neutral,PublicKeyToken=c5687fc88969c44d"/>
    </DbProviderFactories>
  </system.data>
  <entityFramework codeConfigurationType="MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6">
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>    
  </entityFramework>

I tried reinstalling the connector and EF from Nuget, but nothing changed. Can someone please let me know what is going on?

thanks

+4
source share
3 answers

, MySql, Nuget. MySql, . , MySql, GAC .

, ,

MySql

MySql ( v6.8.3)

, .

+3

, .

.NET, , , , MySQL, "web.conf" .

, EF6 MySQL Connector EF v6.8.3.0, :

<entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
        <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6"></provider>
    </providers>
</entityFramework>

, -

+3

I know what the problem is, you need to take the following steps: 1. Right-click on the project 2. Manage NuGet packages 3. Cancel MySql.Data 4. Now you can do what you wanted to do 5. After completion, return in "Manage NuGet Packages" and add MySql.Data.Entity :)

good luck nofar eliasi

0
source

Source: https://habr.com/ru/post/1526191/


All Articles