MySQL and C# Entity Framework "ProviderIncompatibleException"

c# entity-framework entity-framework-6 mysql

Question

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
1
0
7/16/2018 2:02:39 AM

Accepted Answer

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.

3
7/16/2018 2:49:26 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow