我正在尝试使用以下代码将我的Web API连接到MySql数据库:
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
但我总是收到一个带有此描述的System.TypeLoadException:
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.’
我正在使用Microsoft Visual Studio社区2017预览(2),我的项目是在.NET Core 2.0中.我还使用MySql.Data.EntityFrameworkCore.dll和Microsoft.AspNetCore.All(2.0.0-preview2-final).我已经为MySql改变了很多次librairy,但没有成功.
知道为什么总是这样吗?可能是什么原因?
最佳答案
好吧,事实证明你不能使用MySql.Data.EntityFrameworkCore for .Net Core 2.0(现在).我不得不回到.Net Core 1.3来使它工作……我们或许可以在近乎未来的时候使用它!