ADO.NET EF Composite primary key - can not update foreign key
I have following entities:
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.
精彩评论