Beispiel #1
0
 public RegistrationContext(DbContextOptions <RegistrationContext> options)
     : base(options)
 {
     Database.EnsureCreated();
     if (!Colors.Any())
     {
         Colors.Add(new Color {
             name = "Красный"
         });
         Colors.Add(new Color {
             name = "Синий"
         });
         Colors.Add(new Color {
             name = "Желтый"
         });
         this.SaveChanges();
     }
     if (!Drinks.Any())
     {
         Drinks.Add(new Drink {
             name = "Чай"
         });
         Drinks.Add(new Drink {
             name = "Кофе"
         });
         Drinks.Add(new Drink {
             name = "Вода"
         });
         Drinks.Add(new Drink {
             name = "Сок"
         });
         this.SaveChanges();
     }
 }