Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using (IServiceScope scope = host.Services.CreateScope())
- {
- AppDbContext dbCtx = scope.ServiceProvider.GetRequiredService<AppDbContext>();
- dbCtx.Database.Migrate();
- if (!dbCtx.Products.Any())
- {
- dbCtx.Products.Add(
- new Product
- {
- Name = "the Name",
- Description = "the Description"
- });
- dbCtx.SaveChanges();
- }
- }
- modelBuilder.Entity<Product>().HasData(
- new Product
- {
- Id = 1,
- Name = "the Name",
- Description = "the Description"
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement