The DbUpdateException
class contains an Entries
property from which you can extract the collection of the entries failed to persist:
catch (DBUpdateException e)
{
if (IsCustidConflict(e))
{
foreach (var entry in e.Entries)
{
if (entry.Entity is CUSTOMER)
{
var customer = entry.Entity as CUSTOMER;
customer.Custid++;
}
}
continue;
}
}
As a side note, I guess you have a good reason why you aren't letting the database generate the primary-key for you.