Ejemplo n.º 1
0
 public static void InitializeSites(DbContextOptions <ApplicationDbContext> options)
 {
     using (var context = new ApplicationDbContext(options))
     {
         var siteRepository = new SiteRepository(context);
         var repository     = new Repository(context);
         if (!siteRepository.Any())
         {
             siteRepository.Add
                 (new Site
             {
                 Name   = "habr",
                 Domain = "habr.com"
             });
             siteRepository.Add
                 (new Site
             {
                 Name   = "tut.by",
                 Domain = "news.tut.by"
             });
             siteRepository.Add
                 (new Site
             {
                 Name   = "belta",
                 Domain = "www.belta.by"
             });
             repository.SaveChanges();
         }
     }
 }