MySQL and C# Entity Framework "ProviderIncompatibleException"

1

i'm following the MySql tutorial to entity framework as listed here: https://dev.mysql.com/doc/connector-net/en/connector-net-entityframework60.html

I have installed in my project via NuGet:
- Entity Framework v6.2.0
- MySql.Data.Entity v6.10.7

And their corresponding dependencies.

I have installed the MySql CONNECTOR/NET v8.0.11.

I added the provider and connectionString to the App.config:

  <entityFramework codeConfigurationType="MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6">
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
      <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.10.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </providers>
  </entityFramework>

  <connectionStrings>
    <add name="mysql" connectionString="Server=localhost,3306;Database=eneagramas;Uid=root;Pwd=1234;" providerName="MySql.Data.MySqlClient" />
  </connectionStrings>

Basically i followed all the instructions in the official documentation, this is my context class:

class MyContext : DbContext
{
    public MyContext() : base("mysql")
    {
        //nothing here
    }

    public DbSet<Humans> Humans { get; set; }
}

YET i get this error when accesing the DB:

System.Data.Entity.Core.ProviderIncompatibleException
  HResult=0x80131501
  Message=The provider did not return a ProviderManifestToken string.
  Source=EntityFramework
  StackTrace:[...]

Inner Exception 1:
MethodAccessException: Attempt by method 'MySql.Data.MySqlClient.MySqlProviderServices.GetDbProviderManifestToken(System.Data.Common.DbConnection)' to access method 'MySql.Data.MySqlClient.MySqlConnection.get_Settings()' failed.
  • I checked my DB credentials, they are fine
  • The server is up and running
  • The database im trying to use exists
c#
mysql
entity-framework
entity-framework-6
asked on Stack Overflow Jul 16, 2018 by i maed dis

1 Answer

6

You can't use MySql.Data 8.0.11 with MySql.Data.Entity 6.10.7; the major versions are incompatible.

Oracle renamed the package to MySql.Data.EntityFramework for v8. Uninstall MySql.Data.Entity and install MySql.Data.EntityFramework instead.

answered on Stack Overflow Jul 16, 2018 by Bradley Grainger

User contributions licensed under CC BY-SA 3.0