Пример #1
0
 public static void Initialize(ContosoPetsContext _context)
 {
     if (!_context.Products.Any())
     {
         _context.Products.AddRange(
             new Product
         {
             Name  = "Bone",
             Price = 20
         },
             new Product
         {
             Name  = "Belt",
             Price = 10
         }
             );
         _context.SaveChanges();
     }
 }
Пример #2
0
        public static void Initialize(ContosoPetsContext context)
        {
            if (!context.Products.Any())
            {
                context.Products.AddRange(
                    new Product
                {
                    Name  = "Squeaky Bone",
                    Price = 20.99m
                },
                    new Product
                {
                    Name  = "Knotted Rope",
                    Price = 12.99m
                }
                    );

                context.SaveChanges();
            }
        }