Search code examples
mysqlaspnetboilerplate

mySQL Data Provider .NET Core 2.0


Looking for help for some solutions on switching out the default data provider for the project from MS SQL to mySQL. Eventually with the intent of deploying the solution to Auruora on AWS.

After installing the nuget package I get something along the lines of :

System.TypeLoadException: Method 'Clone' in type 'MySql.Data.EntityFrameworkCore.Infraestructure.MySQLOptionsExtension' from assembly 'MySql.Data.EntityFrameworkCore, Version=6.10.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' does not have an implementation.

This lead me to believe that there is no .NET 2.0 Entity Framework Core extention that runs for MySQL. Do I have to rollback to a different version?


Solution

  • For EntityFrameworkCore, it's suggested to use Pomelo.EntityFrameworkCore.MySql. You may refer to their Getting Started documentation.

    A fellow member of the community has kindly summarised the essential steps here:

    1. Put Pomelo.EntityFrameworkCore.MySql into the xxx.EntityFrameworkCore project's .csproj file (see step 2 in the Pomelo getting started guide)
    2. In your xxxDbContextConfigurer class put builder.UseMySql(...) rather than builder.UseSqlServer(...)
    3. Change the connection string found in the appsettings.json file in the xxx.Web.Host project