public async Task InsertItemsSampleData(MesDbContext db) { var items = GetItems(); db.Items.AddRange(items); try { int numAffected = await db.SaveChangesAsync(); _Logger.LogInformation(@"Saved {numAffected} states"); } catch (Exception exp) { _Logger.LogError($"Error in {nameof(MesDbSeeder)}: " + exp.Message); throw; } }
public ItemsRepository(MesDbContext context, ILoggerFactory loggerFactory) { _Context = context; _Logger = loggerFactory.CreateLogger("ItemsRepository"); }