public async Task InsertCustomersSampleData(CustomersDbContext db) { var customers = GetCustomers(); db.Customers.AddRange(customers); try { int numAffected = await db.SaveChangesAsync(); _Logger.LogInformation($"Saved {numAffected} customers"); } catch (Exception exp) { _Logger.LogError($"Error in {nameof(CustomersDbSeeder)}: " + exp.Message); throw; } }
public CustomersRepositoryAsync(CustomersDbContext context, ILoggerFactory loggerFactory) { _Context = context; _Logger = loggerFactory.CreateLogger("CustomersRepository"); }