コード例 #1
0
        public static async Task Main(string[] args)
        {
            var host = CreateWebHostBuilder(args).Build();

            // inserting seeding logic here based on
            // https://stackoverflow.com/questions/46222692/asp-net-core-2-seed-database
            using (var scope = host.Services.CreateScope())
            {
                var context = scope.ServiceProvider
                              .GetRequiredService <HolidayContext>();
                await DbInitialiser.Seed(context);
            }

            host.Run();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: OhDee2/Blog
        public static void Main(string[] args)
        {
            //BuildWebHost(args).Run();
            var host = BuildWebHost(args);

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;
                try
                {
                    var context = services.GetRequiredService <AppDbContext>();
                    DbInitialiser.Seed(context);
                }
                catch (Exception)
                {
                }
            }

            host.Run();
        }
コード例 #3
0
        public static void Main(string[] args)
        {
            //CreateWebHostBuilder(args).Build().Run();
            var host = CreateWebHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;
                try
                {
                    var context = services.GetRequiredService <CrmDbContext>();
                    DbInitialiser.Seed(context);
                }
                catch (Exception)
                {
                    //we could log this in a real-world situation
                }
            }

            host.Run();
        }
コード例 #4
0
ファイル: Startup.cs プロジェクト: sidme/BethanysPieShop
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();

                app.UseStaticFiles(new StaticFileOptions
                {
                    FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @"node_modules")),
                    RequestPath  = new PathString("/vendor")
                });
            }

            app.UseStatusCodePages();
            app.UseStaticFiles();
            app.UseSession();
            app.UseMvcWithDefaultRoute();


            DbInitialiser.Seed(app);
        }