MySql EntityFrameworkCore System.TypeLoadException

asp.net-core-2.0 asp.net-core-webapi entity-framework-core mysql

Question

I am trying to connect my web API to MySql database with this code:

public class Startup
{       
    public void ConfigureServices(IServiceCollection services)
    {
        string conn_string = "server=server;database=database;uid=uid;pwd=pwd;";
        MySqlConnection conn = new MySqlConnection(conn_string);
        services.AddDbContext<TaskContext>(options =>
        {
            options.UseMySQL(conn);
        });
        services.AddMvc();
    }      
    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        app.UseMvc();
    }
}

But I always recieve a System.TypeLoadException with this description:

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

I am using Microsoft Visual Studio Community 2017 Preview (2) and my projet is in .NET Core 2.0. I also use MySql.Data.EntityFrameworkCore.dll and Microsoft.AspNetCore.All (2.0.0-preview2-final). I have changed many times of librairy for MySql but without success.

Any idea why this always happen? What could be the cause?

1
5
8/1/2017 2:21:14 PM

Accepted Answer

Well, it turns out that you can't use MySql.Data.EntityFrameworkCore for .Net Core 2.0(for now). I had to go back to .Net Core 1.3 to make it work... We may be able to use it in a near futur tho!

7
8/2/2017 7:06:53 PM

Popular Answer

Use Pomelo.EntityFrameworkCore.MySql 2.0.0. Works fine for me with .NET Core 2.0



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