public async Task <Crud> InsertAsync(Crud model) { _context.Add(model); try { await _context.SaveChangesAsync(); } catch (System.Exception exp) { _logger.LogError($"Error in {nameof(InsertAsync)}: " + exp.Message); } return(model); }
public async Task InsertCrudSampleData(Ng4DotNetDbContext db) { var crudList = GetCrudList(); db.CrudList.AddRange(crudList); try { int numAffected = await db.SaveChangesAsync(); _Logger.LogInformation($"Saved {numAffected} crudList"); } catch (Exception exp) { _Logger.LogError($"Error in {nameof(Ng4DotNetDbSeeder)}: " + exp.Message); throw; } }