zoukankan      html  css  js  c++  java
  • ABP core学习之一 使用Mysql数据库


    修改项目:EntityFrameworkCore 

    1.添加类库

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

    2.TradeErpDbContextConfigurer

    在TradeErpDbContextConfigurer文件中,将builder.UseSqlServer(connection);修改为builder.UseMySql(connection);

    3.修改原有的迁移语句

    修改原有的迁移语句, 将相关的SqlServer修改为MySql,不然update-database后,id不是auto_increment
    迁移文件.cs
    migrationBuilder.CreateTable(
    name: "AbpEditions",
    columns: table => new
    {
    Id = table.Column<int>(nullable: false)
    .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
    ......
    });
    改为
    migrationBuilder.CreateTable(
    name: "AbpEditions",
    columns: table => new
    {
    Id = table.Column<int>(nullable: false)
    .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
    ......
    });


    迁移文件.Designer.cs

    modelBuilder
    .HasAnnotation("ProductVersion", "1.1.1")
    .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
    改为
    modelBuilder
    .HasAnnotation("ProductVersion", "1.1.1")
    .HasAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn);

    与ef的差异

    在ef core中,使用add-migration xxxx后,撤销的话使用命令remove-migration不能直接删除生成的迁移文件

    因为 xxxDbContextModelSnapshot 快照文件被自动修改了,如果没有一起修改 就会出错。但是手动修改非常麻烦,它不是有序的

  • 相关阅读:
    lua面向对象(定义与调用)
    luastring(字符串)
    luatable(表)
    lua面向对象(创建与实例化)
    pandas安装方法(常规安装失败解决方法)
    lua循环
    windows常用命令schtasks
    ios UI自动化 appium参数配置
    ios UI自动化环境配置
    jmeter进行websocket 通信
  • 原文地址:https://www.cnblogs.com/xcsn/p/10370699.html
Copyright © 2011-2022 走看看