public async Task <T> Add(T entity) { if (entity == null) { throw new ArgumentNullException($"{nameof(Add)} entity must not be null"); } try { await _context.AddAsync(entity); await _context.SaveChangesAsync(); return(entity); } catch (Exception ex) { throw new Exception($"{nameof(entity)} could not be saved: {ex.Message}"); } }