protected virtual void Dispose(bool disposing) { if (!this.disposed) { if (disposing) { entities.Dispose(); } //To clean the transaction always do. this.transaction?.Dispose(); } this.disposed = true; }