public int Delete(int id, byte[] timeStamp, bool persist = true) { var entry = GetEntryFromChangeTracker(id); if (entry != null) { if (entry.Timestamp.SequenceEqual(timeStamp)) { return(Delete(entry, persist)); } throw new Exception("Unable to delete due to concurrency violation."); } Db.Entry(new T { Id = id, Timestamp = timeStamp }).State = EntityState.Deleted; return(persist ? SaveChanges() : 0); }