Good morning, I read several posts and several pages that say that this is not recommended, in fact throws an error by bringing a record, change the password and save. I leave the code:
List<Model> registroAUpdatear = (from s in db.Model where s.Id == IdAnterior select s).ToList();
for (var i = 0; i < registroAUpdatear.Count; i++)
{
registroAUpdatear[i].Id = IdNuevo;
db.Model.Add(registroAUpdatear[i]);
}
This produces an exception:
"The property is part of the object's key information and can not be modified. "
I understand that there is a way to do it, or rather 2 ways:
1-Create a stored procedure that makes the high and low from the DB and call it with entity framework.
2-Make a new Model (), passing the attributes of the model to modify, one by one and then add the new key.
The problem is that these 2 options take a long time for the number of models I have to modify. Can someone come up with another alternative? As much as possible he has gone through the same situation. Thanks!