private static void RunSeeding(IWebHost host)
        {
            IServiceScopeFactory scopeFactory = host.Services.GetService <IServiceScopeFactory>();

            using (IServiceScope scope = scopeFactory.CreateScope())
            {
                SeedDb seeder = scope.ServiceProvider.GetService <SeedDb>();
                seeder.Seed().Wait();
            }
        }
Beispiel #2
0
 private void Seed(IApplicationBuilder app)
 {
     using (var scope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope())
     {
         var context     = scope.ServiceProvider.GetService <IntellectDbContext>();
         var userManager = scope.ServiceProvider.GetService <UserManager <ApplicationUser> >();
         var roleManager = scope.ServiceProvider.GetService <RoleManager <IdentityRole> >();
         context.Database.Migrate();
         SeedDb.Seed(context, userManager, roleManager).Wait();
     }
 }
Beispiel #3
0
 protected void Application_Start(object sender, EventArgs e)
 {
     // Seed Database (Users, Categories, Blogs)
     SeedDb.Seed();
 }