Afshin
Afshin

Reputation: 4215

change primary key with linq in c#

How can I change primary key with linq in c# I try

db.SubmitChange();

an error occur. Then I realized linq does not allow to change primary key field in my c# program How can I fix this problem.

Upvotes: 1

Views: 2155

Answers (1)

Habib
Habib

Reputation: 223257

You can't update a primary key using LINQ. You need to delete that row from the database and add a new one with the new primary key. You can do that in the database using SQL but it should be Unique and shouldn't violate any foreign key constraint.

Upvotes: 2

Related Questions