EF Core for MySql踩坑(一)

1.链接字符串

"ConnectionStrings": {
    "ExamOnlineCon": "server=localhost;user id=root;password=root;database=ExamOnlineDb;charset=utf8;sslMode=None"
  },

2.上下文Context

3.注册服务

 public void ConfigureServices(IServiceCollection services)
 {
     services.AddDbContext<MySqlContext>(options =>
         options.UseMySql(Configuration.GetConnectionString("ExamOnlineCon")));
     services.AddControllersWithViews();
 }

4. 映射数据库

说一下,第三个 " Microsoft.Extensions.Logging.Debug "不用添加


做Code First 映射的时候发现报错了

Method 'get_Info' in type 'MySql.Data.EntityFrameworkCore.Infraestructure.MySQLOptionsExtension' from assembly 'MySql.Data.EntityFrameworkCore, Version=8.0.19.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' does not have an implementation.

上网搜了下资料解释为

不支持 .net core 3.1 的映射,解决办法就是用的这个驱动包

posted @ 2020-02-08 10:16  乾子  阅读(3769)  评论(17编辑  收藏  举报