NET6使用EFCORE CodeFirst现有数据库增加新表

  1. Add-Migration InitialCreate
  2. 注释20230828044500_InitialCreate文件存在的表
     //migrationBuilder.CreateTable(
     //    name: "Device",
     //    columns: table => new
     //    {
     //        ID = table.Column<int>(type: "int", nullable: false)
     //            .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
     //        UserName = table.Column<string>(type: "longtext", nullable: true)
     //            .Annotation("MySql:CharSet", "utf8mb4"),
     //        StationId = table.Column<string>(type: "longtext", nullable: true)
     //            .Annotation("MySql:CharSet", "utf8mb4"),
     //        StationName = table.Column<string>(type: "longtext", nullable: true)
     //            .Annotation("MySql:CharSet", "utf8mb4"),
     //        StationType = table.Column<string>(type: "longtext", nullable: true)
     //            .Annotation("MySql:CharSet", "utf8mb4"),
     //        DeviceId = table.Column<string>(type: "varchar(255)", maxLength: 255, nullable: false)
     //            .Annotation("MySql:CharSet", "utf8mb4"),
     //        DeviceName = table.Column<string>(type: "longtext", nullable: true)
     //            .Annotation("MySql:CharSet", "utf8mb4"),
     //        DeviceType = table.Column<string>(type: "longtext", nullable: true)
     //            .Annotation("MySql:CharSet", "utf8mb4"),
     //        Address = table.Column<string>(type: "longtext", nullable: true)
     //            .Annotation("MySql:CharSet", "utf8mb4"),
     //        Model = table.Column<string>(type: "longtext", nullable: true)
     //            .Annotation("MySql:CharSet", "utf8mb4"),
     //        Version = table.Column<string>(type: "longtext", nullable: true)
     //            .Annotation("MySql:CharSet", "utf8mb4"),
     //        Longitude = table.Column<string>(type: "longtext", nullable: true)
     //            .Annotation("MySql:CharSet", "utf8mb4"),
     //        Latitude = table.Column<string>(type: "longtext", nullable: true)
     //            .Annotation("MySql:CharSet", "utf8mb4"),
     //        OnlineDesc = table.Column<string>(type: "longtext", nullable: true)
     //            .Annotation("MySql:CharSet", "utf8mb4"),
     //        StatusDesc = table.Column<string>(type: "longtext", nullable: true)
     //            .Annotation("MySql:CharSet", "utf8mb4"),
     //        InsertTimeStamp = table.Column<long>(type: "bigint", nullable: false),
     //        UpdateTimeStamp = table.Column<long>(type: "bigint", nullable: false)
     //    },
     //    constraints: table =>
     //    {
     //        table.PrimaryKey("PK_Device", x => x.ID);
     //    })
     //    .Annotation("MySql:CharSet", "utf8mb4");

  3. 执行
     Update-Database

  4. 完成

猜你喜欢

转载自blog.csdn.net/yhjahjj1314/article/details/132537019