/// <summary> /// Add instance to database /// </summary> /// <param name="entity">new instance</param> /// <returns>error message if error happaned, otherwise return instance</returns> public virtual async Task <(T instance, string errorMessage)> AddAsync(T entity) { try { dbContext.Set <T>().Add(entity); await dbContext.SaveChangesAsync(); return(entity, string.Empty); } catch (DbUpdateException e) { return(entity, e?.InnerException?.Message ?? e.Message); } }