public async Task InsertSampleData(ConsignMaxDbContext db) { var states = GetStates(); db.States.AddRange(states); try { int numAffected = await db.SaveChangesAsync(); _Logger.LogInformation(@"Saved {numAffected} states"); } catch (Exception exp) { _Logger.LogError($"Error in {nameof(ConsignMaxDbSeeder)}: " + exp.Message); throw; } var consignors = GetConsignors(); db.Consignors.AddRange(consignors); try { int numAffected = await db.SaveChangesAsync(); _Logger.LogInformation(@"Saved {numAffected} consignors"); } catch (Exception exp) { _Logger.LogError($"Error in {nameof(ConsignMaxDbSeeder)}: " + exp.Message); throw; } }
public async Task <Consignor> InsertConsignorAsync(Consignor Consignor) { _Context.Add(Consignor); try { await _Context.SaveChangesAsync(); } catch (System.Exception exp) { _Logger.LogError($"Error in {nameof(InsertConsignorAsync)}: " + exp.Message); } return(Consignor); }