2

I am not able to get asp.net mvc5 identity to work with mysql. Here is the web.config part .Could it be beacuse of EF6 not working with mvc5 ?

<system.data>
    <DbProviderFactories>
      <remove name="MySQL Data Provider"/>

      <add name="MySQL Data Provider"
          invariant="MySql.Data.MySqlClient"
          description=".Net Framework Data Provider for MySQL"
          type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
  </system.data>

entityFramework>
    <defaultConnectionFactory type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data" />
      <providers>
        <provider invariantName="MySql.Data.MySqlClient"
                  type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity" />
      </providers>


  </entityFramework>

The error is :

Additional information: The 'Instance' member of the Entity Framework provider type 'MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity, Version=6.7.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' did not return an object that inherits from 'System.Data.Entity.Core.Common.DbProviderServices'. Entity Framework providers must inherit from this class and the 'Instance' member must return the singleton instance of the provider. This may be because the provider does not support Entity Framework 6 or later

4 Answers 4

1

That because you are referencing EF 6, and MySQL Connector still does not support EF6. You can either downgrade to EF 5 or get the MySQL Connector Alpha.

Do this (KEEP A COPY OF WHAT YOU JUST PASTED):

  1. Erase all references to EF6
  2. Get EF 5 from Nuget (open a NuGet console and type Install-Package EntityFramework -Version 5.0.0 )
  3. Regenerate your Entities
  4. Make sure you get the <DbProviderFactories> and <providers> sections just like you have.
Sign up to request clarification or add additional context in comments.

1 Comment

Getting following error message -- Install-Package : Updating 'EntityFramework 6.0.1' to 'EntityFramework 5.0.0' failed. Unable to find a version of 'Microsoft.AspNet.Identity.EntityFramework' that is compatible with 'EntityFramework 5.0.0'.
0

After you do what David suggested look in all of the App.config files and make sure that all of the depdentAssembly settings look something like this.

  <dependentAssembly>
    <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
  </dependentAssembly>

The important part is the bindingRedirect.

Comments

0

I came across the MySql.Data.Entity.EF6 NuGet package which should fix your issue. I found I had to completely remove all references to MySql and EF before I could get this to work properly (including all web.config references). The package has a dependency on EF6, so will install it as part of the package install process.

Comments

0

You can also use finished implementation of MySQL ASP.NET Identity 2.1 provider which uses ADO.NET to communicate with MySQL. This is available as NuGet package and you can read more on this blog post: ASP.NET Identity 2.1 implementation for MySQL

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.