I am trying to replace a user ID in a SQL Table column with another user ID but getting the Error "The property 'User_Id' is part of the object's key information and cannot be modified. " Below is my code.
using (var context = new Model())
{
var model = context.HeaderRoles
.Where(f => f.User_Id.Equals(OldUserId))
.ToList();
model.ForEach(f => f.User_Id = NewUserId);
foreach (var headerRole in model)
context.HeaderRoles.Add(headerRole);
context.SaveChanges();
return Json(model, JsonRequestBehavior.AllowGet);
}