using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace VOL.Core.Migrations { public partial class _20250313v1 : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Y_Stadium", columns: table => new { Id = table.Column(type: "int", nullable: false, comment: "Id") .Annotation("SqlServer:Identity", "1, 1"), StadiumCode = table.Column(type: "nvarchar(100)", nullable: true, comment: "场馆编号"), StadiumName = table.Column(type: "nvarchar(100)", nullable: true, comment: "场馆名称"), Province = table.Column(type: "nvarchar(20)", nullable: true, comment: "所属省份"), City = table.Column(type: "nvarchar(20)", nullable: true, comment: "所属城市"), Area = table.Column(type: "nvarchar(20)", nullable: true, comment: "所属区域"), Address = table.Column(type: "nvarchar(2000)", nullable: true, comment: "地址"), PhoneNo = table.Column(type: "nvarchar(2000)", nullable: true, comment: "联系电话"), Latitude = table.Column(type: "float", nullable: false, comment: "纬度"), Longitude = table.Column(type: "float", nullable: false, comment: "经度"), Intro = table.Column(type: "text", nullable: true, comment: "介绍"), CoverImage = table.Column(type: "nvarchar(2000)", nullable: true, comment: "封面图"), Remarks = table.Column(type: "text", nullable: true, comment: "备注"), Creator = table.Column(type: "int", nullable: false, comment: "创建人"), // 修正了 `type` 语法错误 CreateDate = table.Column(type: "datetime", nullable: false, comment: "创建时间"), Modifier = table.Column(type: "int", nullable: false, comment: "修改人"), // 修正了 `type` 语法错误 ModifyDate = table.Column(type: "datetime", nullable: true, comment: "修改时间") }, constraints: table => { table.PrimaryKey("PK_Y_Stadium", x => x.Id); }); migrationBuilder.CreateTable( name: "Y_StadiumResource", columns: table => new { Id = table.Column(type: "int", nullable: false, comment: "Id") .Annotation("SqlServer:Identity", "1, 1"), StadiumId = table.Column(type: "int", nullable: false, comment: "场馆Id"), // 确保 StadiumId 不为空 Type = table.Column(type: "int", nullable: false, comment: "资源类型[1:图片/2:视频]"), Url = table.Column(type: "nvarchar(2000)", nullable: true, comment: "资源地址") }, constraints: table => { table.PrimaryKey("PK_Y_StadiumResource", x => x.Id); table.ForeignKey( name: "FK_Y_StadiumResource_Y_Stadium_StadiumId", column: x => x.StadiumId, principalTable: "Y_Stadium", principalColumn: "Id", onDelete: ReferentialAction.Cascade); // 设定级联删除 }); migrationBuilder.CreateIndex( name: "IX_Y_StadiumResource_StadiumId", table: "Y_StadiumResource", column: "StadiumId"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Y_StadiumResource"); migrationBuilder.DropTable( name: "Y_Stadium"); } } }