public async Task <IEModel <CategoryModel> > Add(CategoryModel category) { try { EntityEntry <CategoryModel> addedCategory = await context.Categories.AddAsync(category); await context.SaveChangesAsync(); return(new IEModel <CategoryModel>("", CustomErrorCode.Sucess, addedCategory.Entity)); } catch (DbUpdateException ex) { return(new IEModel <CategoryModel>($"Erro ao salvar adição: {ex.Message}", CustomErrorCode.NoOperation, (CategoryModel)(ex.Entries.First().Entity))); } }