// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseStatusCodePages(); app.UseStaticFiles(); app.UseDeveloperExceptionPage(); app.UseAuthentication(); app.UseMvcWithDefaultRoute(); //The wait method in the end is beacause the method CreateAdminAccount is Task AppIdentityDbContext.CreateAdminAccount(app.ApplicationServices, Configuration).Wait(); SeedMovieData.SeedMovies(app, Configuration).Wait(); }
public static void Main(string[] args) { var host = CreateWebHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { var context = services.GetRequiredService <DataContext>(); context.Database.Migrate(); SeedMovieData.Initialize(services); } catch (System.Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occured seeding the DB."); } } host.Run(); }