【发布时间】:2017-05-23 21:30:10
【问题描述】:
当我尝试将列类型从 datetime 更改为 smallint 时,EF Core 更新数据库失败:“操作数类型冲突:日期与 smallint 不兼容”
迁移文件:
公共部分类 BookYearFieldChanged:迁移
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<short>(
name: "Published",
table: "Books",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "date");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<DateTime>(
name: "Published",
table: "Books",
type: "date",
nullable: false,
oldClrType: typeof(short));
}
}
【问题讨论】:
标签: c# sql sql-server entity-framework