public void Seed() { _ctx.Database.EnsureCreated(); if (!_ctx.Comics.Any()) { var filepath = Path.Combine(_hosting.ContentRootPath, "Data/SampleComics.json"); var json = File.ReadAllText(filepath); var comics = JsonConvert.DeserializeObject <IEnumerable <Comic> >(json); _ctx.Comics.AddRange(comics); _ctx.SaveChanges(); } }
public bool SaveAll() { return(_ctx.SaveChanges() > 0); }