Esempio n. 1
0
        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();
            }
        }
Esempio n. 2
0
 public bool SaveAll()
 {
     return(_ctx.SaveChanges() > 0);
 }