本文介绍了使用Entity Framework Core迁移更改主键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图通过Entity Framework Core Migrations更改表的主键:
I am trying to Change the Primary key of a table via Entity Framework Core Migrations:
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropPrimaryKey( name: "PK_Permissions", table: "Permissions"); }当我尝试更新数据库时,出现以下错误消息:
When I try to update the database I get the following error message:
To change the IDENTITY property of a column, the column needs to be dropped and recreated.如何更新数据库?
推荐答案我找到了一个解决方案:这似乎是EF Core 1.1中的错误
I have found a solution: This seems to be a bug in EF Core 1.1
我更改了迁移
有关此信息的更多信息,请参见: thisworksonmymachine/2017/02/13/ef-core-the-setup-part-4/
More Information about this can be found here: thisworksonmymachine/2017/02/13/ef-core-the-setup-part-4/
更多推荐
使用Entity Framework Core迁移更改主键
发布评论