使用Entity Framework Core迁移更改主键

编程入门 行业动态 更新时间:2024-10-28 14:27:54
本文介绍了使用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迁移更改主键

本文发布于:2023-10-16 00:47:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1495983.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:主键   Entity   Framework   Core

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!