public void Seed() { _ctx.Database.EnsureCreated(); if (!_ctx.Employees.Any()) { var path = Path.Combine(_hosting.ContentRootPath, "Data/StarterData.json"); var json = File.ReadAllText(path); var employees = JsonConvert.DeserializeObject <IEnumerable <Employee> >(json); _ctx.Employees.AddRange(employees); _ctx.SaveChanges(); } }
public void AddEmployee(Employee employee) { _ctx.Employees.Add(employee); _ctx.SaveChanges(); }