Beispiel #1
0
        public static async Task Main(string[] args)
        {
            var host = CreateHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var uow = scope.ServiceProvider.GetService <IUnitOfWork>();
                // await SeedData(uow);

                var seeder = new DataSeeder();
                seeder.SeedData(uow);
            }

            host.Run();
        }
Beispiel #2
0
        public static async Task Main(string[] args)
        {
            var host = CreateHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;

                var context        = services.GetRequiredService <ApplicationDbContext>();
                var passwordHasher = services.GetRequiredService <IPasswordHasher>();
                context.Database.Migrate();
                await DataSeeder.SeedData(context, passwordHasher);
            }

            await host.RunAsync();
        }
Beispiel #3
0
 // 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();
     }
     using (var serviceScope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope())
     {
         var context = serviceScope.ServiceProvider.GetRequiredService <Models.ApiDbContext>();
         context.Database.EnsureCreated();
         DataSeeder.SeedShops(context);
         DataSeeder.SeedItems(context);
     }
     app.UseCors(builder => builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod().AllowCredentials());
     app.UseMvc();
 }
Beispiel #4
0
        public static void Main(string[] args)
        {
            var host = CreateHostBuilder(args).Build();

            using var scope = host.Services.CreateScope();
            var services = scope.ServiceProvider;

            try
            {
                var ctx = services.GetRequiredService <OverflowDbContext>();
                ctx.Database.Migrate();
                DataSeeder.Initialize(ctx);
            }
            catch (Exception e)
            {
                Console.WriteLine("An error occurred while creating tables: " + e.Message);
            }
            host.Run();
        }
Beispiel #5
0
        public static void Main(string[] args)
        {
            var host = CreateHostBuilder(args).Build();

            using var scope = host.Services.CreateScope();
            var services = scope.ServiceProvider;

            try
            {
                var context = services.GetRequiredService <WebApiDbContext>();
                context.Database.Migrate();
                DataSeeder.SeedDatabase(context);
            }
            catch (Exception e)
            {
                Console.WriteLine("An error occurred while seeding the database: " + e.Message);
            }
            finally
            {
                host.Run();
            }
        }