Esempio n. 1
0
        public MainContext(DbContextOptions <MainContext> options) : base(options)
        {
            if (!Dishes.Any())
            {
                Dishes.Add(new Dish()
                {
                    Name = "Plate"
                });
                Dishes.Add(new Dish()
                {
                    Name = "Fork"
                });
                Dishes.Add(new Dish()
                {
                    Name = "Knife"
                });
                SaveChanges();
            }

            if (!Fruits.Any())
            {
                Fruits.Add(new Fruit()
                {
                    Name = "Apple"
                });
                Fruits.Add(new Fruit()
                {
                    Name = "Orange"
                });
                Fruits.Add(new Fruit()
                {
                    Name = "Kiwi"
                });
                SaveChanges();
            }

            if (!Vegetables.Any())
            {
                Vegetables.Add(new Vegetable()
                {
                    Name = "Cucumber"
                });
                Vegetables.Add(new Vegetable()
                {
                    Name = "Tomato"
                });
                Vegetables.Add(new Vegetable()
                {
                    Name = "Carrot"
                });
                SaveChanges();
            }
        }