Example #1
0
 public static void Initialize(IServiceProvider serviceProvider)
 {
     using (var context = new SandwichContext(
                serviceProvider.GetRequiredService <DbContextOptions <SandwichContext> >()))
     {
         if (context.Sandwich.Any())
         {
             return;
         }
         context.Sandwich.AddRange(
             new Sandwich
         {
             Name     = "BLT",
             Birthday = DateTime.Parse("1996-11-8"),
             Price    = 5.00M,
             Rating   = "Great!"
         },
             new Sandwich
         {
             Name     = "Club",
             Birthday = DateTime.Parse("1492-2-2"),
             Price    = 22.22M,
             Rating   = "Good!"
         }
             );
         context.SaveChanges();
     }
 }
Example #2
0
 public DeleteModel(WebApplication1.Models.SandwichContext context)
 {
     _context = context;
 }
Example #3
0
 public IndexModel(WebApplication1.Models.SandwichContext context)
 {
     _context = context;
 }