// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, SeedContext seedData) { app.UseMiddleware <ErrorHandlingMiddleware>(); if (env.IsDevelopment()) { //app.UseDeveloperExceptionPage(); } //app.UseHttpsRedirection(); seedData.SeedAsync(); app.UseRouting(); app.UseCors(x => x.AllowAnyHeader() .AllowAnyMethod() .AllowCredentials() .WithOrigins("http://localhost:4200")); app.UseAuthentication(); app.UseAuthorization(); app.UseDefaultFiles(); app.UseStaticFiles(); app.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider( Path.Combine(env.ContentRootPath, "MyStaticFiles")), RequestPath = "/StaticFiles" }); app.UseEndpoints(endpoints => { endpoints.MapControllers(); endpoints.MapHub <AdminHub>("/hubs/AdminHub"); endpoints.MapHub <KiosksHub>("/hubs/KiosksHub"); endpoints.MapFallbackToController("Index", "Fallback"); }); }
protected override void Seed(Context.WsContext context) { using (var seedContext = new SeedContext(context, runDispose: false)) { SeedLoader.LoadSeeders(seedContext); } }
public static void Main(string[] args) { var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { SeedContext.Initialize(services); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occurred when seeding the DB."); } } host.Run(); }
public static async Task Main(string[] args) { var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; var loggerFactory = services.GetRequiredService <ILoggerFactory>(); try { var dbContext = services.GetRequiredService <DoorManagementDbContext>(); await SeedContext.SeedAsync(dbContext, loggerFactory); } catch (Exception ex) { var logger = loggerFactory.CreateLogger <Program>(); logger.LogError(ex, "An error occurred seeding the database."); } } host.Run(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public async void Configure(IApplicationBuilder app, IWebHostEnvironment env, SeedContext seedContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); using (var scope = app.ApplicationServices.CreateScope()) { await seedContext.Seed(scope.ServiceProvider.GetService <DatabaseContext>()); } app.UseSpaStaticFiles(); app.UseSpa(spa => { spa.Options.SourcePath = "client-app"; if (env.IsDevelopment()) { spa.UseVueDevelopmentServer(true); } }); }
public CsvSqlServerDestinyTests() { SeedContext.Execute(); data = SeedContext.GetMockData(); }
public SeedController(SeedContext context) { _context = context; }