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

Posted anthony518

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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);

以上是关于EF Core 迁移时将字段由不允许为空改变为允许为空修改字段长度限制的主要内容,如果未能解决你的问题,请参考以下文章