I have a list of updated objects. And I tried to update all records with only one database call.(one context.SaveChanges() command). This programme runs inside a windows service. My problem is instead of updating I am multiplicating all records on the database and adding duplicates. Following is my code.
//adding the list of updated customer objects to the list
context_CLTUS.Customer_Updates.AddRange(list.customerUpdateList);
foreach (var j in list.customerUpdateList)
{
//calling entity state modify for each record
context_CLTUS.Entry(j).State = EntityState.Modified;
}
//save updated list in one db call.
context_CLTUS.SaveChanges();
I cannot clarify why all records are duplicating instead of updating. Could you please explain and help me on this. Thank you.