How can I create a copy an existent entity(dbset) but changing the primary key?
For example, I have the code below:
foreach(var item in db.PedidoMassPro_Detail.Where(o => o.Order_Number.Equals(orderNumber)))
{
PedidoMassPro_Detail newItem = item;
newItem.Order_Number = "TESTE111";
db.PedidoMassPro_Detail.Add(newItem);
db.SaveChanges();
}
I get the error: New transaction is not allowed because there are other threads running in the session.
There is a lot of columns, so that is the reason why I not setting each column, I will need a copy and the only thing that I need to change is the Primary Key (Order_Number).