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);


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM