public static void EnsurePopulated(WebApplication app)
        {
            ChangeReturnDbContext context = app.Services
                                            .CreateScope().ServiceProvider.GetRequiredService <ChangeReturnDbContext>();

            if (context.Database.GetPendingMigrations().Any())
            {
                context.Database.Migrate();
            }

            if (!context.Products.Any())
            {
                context.Products.AddRange(
                    new Product
                {
                    Name  = "Soda",
                    Price = 1.50m
                });

                context.SaveChanges();
            }
        }
Esempio n. 2
0
 public AddItemModel(ChangeReturnDbContext context)
 {
     _context = context;
 }
Esempio n. 3
0
 public IndexModel(ChangeReturnDbContext context, SignInManager <IdentityUser> signInManager)
 {
     _context       = context;
     _signInManager = signInManager;
 }