I am trying to do an update on a record in my database using linq2sql, however, I am getting the following exception thrown:
'System.Data.Linq.DuplicateKeyException' in System.Data.Linq.dll ("Cannot add an entity with a key that is already in use.") System.Data.Linq.DuplicateKeyException
Although I understand what the exception is telling me, how is this possible when doing an update? I am not inserting any data so realistically no keys should be updated?
var Printer = db.Printers.FirstOrDefault(p => p.id == i.PrinterId);
Printer.CenterId = GetCenterId(i.NewCenterCode);
Printer.LastCenterCode = i.NewCenterCode;
db.SubmitChanges();
Any ideas?