Exemplo n.º 1
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new FoodBankContext(
                       serviceProvider.GetRequiredService <DbContextOptions <FoodBankContext> >()))
            {
                // Look for any movies.
                if (context.FoodItem.Count() > 0)
                {
                    return;   // DB has been seeded
                }

                context.FoodItem.AddRange(
                    new FoodItem
                {
                    Title    = "Is Mayo an Instrument?",
                    Url      = "https://i.kym-cdn.com/photos/images/original/001/371/723/be6.jpg",
                    Tags     = "spongebob",
                    Uploaded = "07-10-18 4:20T18:25:43.511Z",
                    Width    = "768",
                    Height   = "432"
                }


                    );
                context.SaveChanges();
            }
        }
Exemplo n.º 2
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new FoodBankContext(
                       serviceProvider.GetRequiredService <DbContextOptions <FoodBankContext> >()))
            {
                // Look for any movies.
                if (context.FoodItem.Count() > 0)
                {
                    return;   // DB has been seeded
                }

                context.FoodItem.AddRange(
                    new FoodItem
                {
                    Calories  = "301",
                    Id        = "1997",
                    Item_Name = "Taco",
                }


                    );
                context.SaveChanges();
            }
        }