创建项目

使用ABP官方网站创建一个基础项目https://aspnetboilerplate.com/Templates

修改XXX.EntityFrameworkCore项目

引用mysql

  • 使用nuget包管理器,添加 Pomelo.EntityFrameworkCore.MySql

  • 修改XXXDbContextConfigurer类

 public static class VMSDbContextConfigurer
    {
        public static void Configure(DbContextOptionsBuilder<VMSDbContext> builder, string connectionString)
        {
            //builder.UseSqlServer(connectionString);
            builder.UseMySql(connectionString, GetVersion());
        }

        public static void Configure(DbContextOptionsBuilder<VMSDbContext> builder, DbConnection connection)
        {
            //builder.UseSqlServer(connection);
            builder.UseMySql(connection, GetVersion());
        }
        private static ServerVersion GetVersion()
        {
            var version = new System.Version("5.7.26");
            return ServerVersion.Create(version, ServerType.MySql);
        }
    }

迁移相关处理

  • 删掉Migrations文件夹下的文件
  • 修改Web.Host项目的数据库连接语句
  • 重新生成迁移信息
add-migration
update-database -verbose

到此,可以看到数据库自动生成成功了

相关文章:

  • 2021-06-23
  • 2021-07-11
  • 2022-01-28
  • 2022-12-23
  • 2021-07-06
  • 2021-10-28
  • 2021-04-03
猜你喜欢
  • 2022-01-21
  • 2022-12-23
  • 2022-01-31
  • 2021-08-02
  • 2021-10-15
相关资源
相似解决方案