Beispiel #1
0
        public static void Initialize(SportStoreContext ctx)
        {
            ctx.Database.EnsureCreated();

            if (!ctx.Products.Any())
            {
                ctx.Products.AddRange(
                    new Product {
                    Name = "Football", Price = 25
                },
                    new Product {
                    Name = "Surf board", Price = 179
                },
                    new Product {
                    Name = "Running shoes", Price = 95
                }
                    );

                ctx.SaveChanges();
            }
        }
Beispiel #2
0
 public ProductRepository(SportStoreContext context)
 {
     ctx = context;
 }