示例#1
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new VitecMVCContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <VitecMVCContext> >()))
            {
                if (context.Product.Any())
                {
                    return;   // DB has been seeded
                }

                context.Product.AddRange(
                    new Products
                {
                    Title = "CD-ORD",
                    ProductDescription = "Til dig, der er pisse blind og bare savner diktat i folkeren",
                    Price = 441
                },

                    new Products
                {
                    Title = "Into-Words ",
                    ProductDescription = "Lær at læs nemt af helvede til",
                    Price = 554
                },

                    new Products
                {
                    Title = "Læsebriller",
                    ProductDescription = "Hvis du er pisse blind, men kun tæt på",
                    Price = 300
                }
                    );
                context.SaveChanges();
            }
        }
示例#2
0
 public ProductsController(VitecMVCContext context)
 {
     _context = context;
 }