public async Task InsertCustomersSampleData(CustomersDbContext db) { var states = GetStates(); db.States.AddRange(states); try { await db.SaveChangesAsync(); } catch (Exception exp) { _logger.LogError($"Error in {nameof(CustomersDbSeeder)}: " + exp.Message); throw; } var customers = GetCustomers(states); db.Customers.AddRange(customers); try { await db.SaveChangesAsync(); } catch (Exception exp) { _logger.LogError($"Error in {nameof(CustomersDbSeeder)}: " + exp.Message); throw; } }
public async Task <Customer> InsertCustomerAsync(Customer customer) { _context.Add(customer); try { await _context.SaveChangesAsync(); } catch (System.Exception exp) { _logger.LogError($"Error in {nameof(InsertCustomerAsync)}: " + exp.Message); } return(customer); }