EF Core 迁移时将字段由不允许为空改变为允许为空、修改字段长度限制

允许为空

migrationBuilder.AlterColumn<string>(
name: "BirthData",
table: "Demo_Author",
type: "datetimeoffset(7)",
nullable: true,
oldNullable:false);

修改字段长度限制

migrationBuilder.AlterColumn<string>(
name: "Email",
table: "Demo_Author",
maxLength: 30,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);

migrationBuilder.AlterColumn<string>(
name: "Email",
table: "App_User",
maxLength: 40,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);

猜你喜欢

转载自www.cnblogs.com/Anthony518/p/12812159.html