Example #1
0
        public static void EnsurePopulated(IApplicationBuilder app)
        {
            ApplicationDBContext context = app.ApplicationServices.GetRequiredService <ApplicationDBContext>();

            context.Database.Migrate();
            if (!context.Products.Any())
            {
                context.Products.AddRange(
                    new Product
                {
                    Name        = "Kayak",
                    Description = "A boat for one person",
                    Category    = "Watersports",
                    Price       = 275
                },
                    new Product
                {
                    Name        = "Lifejacket",
                    Description = "Protectible and fashionable",
                    Category    = "Watersports",
                    Price       = 48.95m
                },
                    new Product
                {
                    Name        = "Soccer ball",
                    Description = "Fifa-approved size and weight",
                    Category    = "soccer",
                    Price       = 19.50m
                },
                    new Product
                {
                    Name        = "Thinking cap",
                    Description = "Improve brain efficiency by 75%",
                    Category    = "Chess",
                    Price       = 16m
                },
                    new Product
                {
                    Name        = "Corner Flags",
                    Description = "Give your playing field a professional touch",
                    Category    = "soccer",
                    Price       = 34.95m
                },
                    new Product
                {
                    Name        = "Unsteady Chair",
                    Description = "Secretly give your opponent a disadvantage",
                    Category    = "chess",
                    Price       = 29.95m
                },
                    new Product
                {
                    Name        = "Human Chess Board",
                    Description = "A fun game for the family",
                    Category    = "Chess",
                    Price       = 75
                },
                    new Product
                {
                    Name        = "Stadium",
                    Description = "Flat-packed 35,000-seat stadium",
                    Category    = "Chess",
                    Price       = 79500
                },
                    new Product
                {
                    Name        = "bling bling king",
                    Description = "gold plated, diamond",
                    Category    = "Chess",
                    Price       = 1200
                });

                context.SaveChanges();
            }
        }
Example #2
0
        public static void EnsurePopulated(IApplicationBuilder app)
        {
            ApplicationDBContext context = app.ApplicationServices
                                           .GetRequiredService <ApplicationDBContext>();


            context.Database.Migrate();
            if (!context.Products.Any())
            {
                context.Products.AddRange(
                    new Product
                {
                    Name        = "Kayak",
                    Description = "A boat for one person",
                    Price       = 275M,
                    Category    = "Soccor"
                },
                    new Product
                {
                    Name        = "Life Jacket",
                    Description = "Protective and Fashionable",
                    Price       = 48.9M,
                    Category    = "Soccor"
                },
                    new Product
                {
                    Name        = "Soccer Ball",
                    Description = "FIFA-Approved size and weight",
                    Price       = 19.50M,
                    Category    = "Soccor"
                },
                    new Product
                {
                    Name        = "Corner Flags",
                    Description = "Give your playing field a professional touch",
                    Price       = 34.95M,
                    Category    = "Soccor"
                },
                    new Product
                {
                    Name        = "New york Stadium",
                    Description = "A flat-packed 50,000 seat staduim",
                    Price       = 79500,
                    Category    = "Soccor"
                },
                    new Product
                {
                    Name        = "Thinking Cap",
                    Description = "Improves brain efficiency by 75%",
                    Price       = 16,
                    Category    = "Chess"
                },
                    new Product
                {
                    Name        = "Unsteady Chair",
                    Description = "The way it rocks, it throws off your opponents. Roll with it",
                    Price       = 29.95M,
                    Category    = "Chess"
                },
                    new Product
                {
                    Name        = "Human Chess boards",
                    Description = "A family fun Game ( Humans and family not included.)",
                    Price       = 75,
                    Category    = "Chess"
                },
                    new Product
                {
                    Name        = "The Bling-bling King",
                    Description = "Gold plated, Diamond-studded King Win or lose In style",
                    Price       = 1200,
                    Category    = "Chess"
                },
                    new Product
                {
                    Name        = "Test test test",
                    Description = "This is a god damn test ",
                    Price       = 999999,
                    Category    = " This shit doesn't work"
                }
                    ); context.SaveChanges();
            }
        }