开发者

ADO.NET EF Composite primary key - can not update foreign key

开发者 https://www.devze.com 2023-01-16 12:57 出处:网络
I have following entities: In my code I need to update the FKCategoryID开发者_开发知识库 in entity BudgetPost but I\'m getting the following error:

I have following entities:

ADO.NET EF Composite primary key - can not update foreign key

In my code I need to update the FKCategoryID开发者_开发知识库 in entity BudgetPost but I'm getting the following error:

FKCategoryID is part of the object's key information

Is it any way to update the key in this case or it's not possible?

Thanks in advance


Why is it a part of the composite key? As long as FKBudgetID is a part of the composite primary key you won't be able to modify it. If you want to enforce uniqueness in the combination of FKCategoryID and FKBudgetID, use a UNIQUE constraint instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消