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(); } }
public AddItemModel(ChangeReturnDbContext context) { _context = context; }
public IndexModel(ChangeReturnDbContext context, SignInManager <IdentityUser> signInManager) { _context = context; _signInManager = signInManager; }