MySql.Data.MySqlClient.MySqlProviderServices.GetDbProviderManifestToken to access method MySql.Data.MySqlClient.MySqlConnection.get_Settings() failed

Lukman Hakim Imran 1 Reputation point
2022-10-15T11:24:12.84+00:00

To Upgrade

Database: MySql Version 5.5.62 to 8.0.28
.NET Framework: Version 4.5 to 4.8
Entity Framework: Version 5.0.0 to 6.4.4

I followed the following steps:

  • Uninstall and remove all existing mySQL dll of my project
  • Uninstall Existing MySql Server
  • Download the MySql Installer version of 8.0.28 and Install MySql Server
  • Install .NET Connector - 8.0.28

DLL's

 C:\Program Files (x86)\MySQL\MySQL Connector Net 8.0.28\Assemblies\v4.8\mysql.data.entity.EF6.dll  
 C:\Program Files (x86)\MySQL\MySQL Connector Net 8.0.28\Assemblies\v4.8\MySql.Data.dll   
 C:\Program Files (x86)\MySQL\MySQL Connector Net 8.0.28\Assemblies\v4.5.2\MySql.Data.EntityFramework.dll  
  • Change the Target Framework for the Project to .NET Framework 4.8
  • Install MySql.Data -8.0.28.0 (NuGet Package Manager)
  • Install MySql.Data.EntityFramework -8.0.28.0 (NuGet Package Manager)
  • Install MySql.Data.Entities -6.8.3.0 (It's not MySql.Data.Entity but MySql.Data.Entities. MySql.Data.Entity has been deprecated as it is legacy and is no longer maintained. According to this Answer, need to Uninstall MySql.Data.Entity But My project doesn't contain it because of done step 1)
  • Install Entity Framework -6.4.4 (Upgraded from 5.0.0)
  • Install mysql-for-visualstudio -1.2.8 (Using VS2022)
  • In Global.asax.cs using MySql.Data.Entity; In Application_Start()

DbConfiguration.SetConfiguration(new MySqlEFConfiguration());

  • In Database Context

using MySql.Data.Entity;

[DbConfigurationType(typeof(MySqlEFConfiguration))]  
public partial class my_systemContext : DbContext  
{  
    static my_systemContext()  
    {  
        DbConfiguration.SetConfiguration(new MySqlEFConfiguration());  
        Database.SetInitializer<my_systemContext>(null);  
    }  
  
    public my_systemContext()   
        : base("Name=my_systemContext")  
    {  
  
    }  
}  
  • Package Config:

<package id="EntityFramework" version="6.4.4" targetFramework="net48" />
<package id="MySql.Data" version="8.0.28" targetFramework="net48" />
<package id="MySql.Data.Entities" version="6.8.3.0" targetFramework="net48" />
<package id="MySql.Data.EntityFramework" version="8.0.28" targetFramework="net48" />

  • In Web.Config:

=> Config Section:

<configSections>  
        <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 and EntityFramework

<system.data>  
        <DbProviderFactories>  
            <remove invariant="MySql.Data.MySqlClient" />  
            <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=8.0.28, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />  
        </DbProviderFactories>  
</system.data>  
    <entityFramework codeConfigurationType="MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6">  
        <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" />  
        </providers>  
    </entityFramework>  

=> Connection String and Run Time dependentAssembly

<connectionStrings>  
        <remove name="my_systemContext" />  
        <add name="my_systemContext" connectionString="server=localhost;User Id=root;password=MyPassword;Persist Security Info=True;database=my_system;Convert Zero Datetime=True" providerName="MySql.Data.MySqlClient" />  
    </connectionStrings>  
  
<runtime>  
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">  
      <dependentAssembly>  
        <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />  
        <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="6.0.0.0" />  
      </dependentAssembly>  
      <dependentAssembly>  
        <assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />  
        <bindingRedirect oldVersion="0.0.0.0-8.0.28.0" newVersion="8.0.28.0" />  
      </dependentAssembly>  
  
        </assemblyBinding>  
    </runtime>  

But now application is able to log on by using ASP.NET membership but can't process the LINQ query. Here I am getting the following error:

Attempt by method
'MySql.Data.MySqlClient.MySqlProviderServices.GetDbProviderManifestToken(System.Data.Common.DbConnection)' to access method 'MySql.Data.MySqlClient.MySqlConnection.get_Settings()' failed.

Note: Firstly I tried for latest version 8.0.31. But same problem I found. What I have missed for completing the task or is there any issue of incompatible version? Do I have to downgrade? Need your help to fix up.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,603 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Lukman Hakim Imran 1 Reputation point
    2022-10-16T06:37:23.267+00:00

    Finally, I solved the issue.
    Just modified the provider tag in web.config

    <!--<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />-->  
      
     <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.EntityFramework, Version=8.0.28.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>  
    
    0 comments No comments