public static void SaveChangesWithConcurrencyConflictsResolving(this ISqlServerDbContext dbContext) { if (dbContext is null) { throw new ArgumentNullException(nameof(dbContext)); } while (true) { try { dbContext.SaveChanges(); break; } catch (DbUpdateConcurrencyException ex) { if (ex.Entries.Count == 0) { throw; } foreach (var entry in ex.Entries) { entry.State = EntityState.Detached; } } } }
public void SaveChanges() => _dbContext.SaveChanges();