コード例 #1
0
        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;
            }
        }
コード例 #2
0
 public CustomersRepositoryAsync(CustomersDbContext context, ILoggerFactory loggerFactory)
 {
     _Context = context;
     _Logger  = loggerFactory.CreateLogger("CustomersRepository");
 }