Exemple #1
0
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            SeedDB seed = new SeedDB(modelBuilder);

            seed.Seed();
        }
Exemple #2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ApplicationDbContext context, UserManager <ApplicationUser> userManager)
        {
            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseAuthentication();

            app.UseSession();

            SeedDB.Seed(context, userManager);

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Exemple #3
0
        static void Main(string[] args)
        {
            var seeder = new SeedDB();

            seeder.Seed();
            DapperExtensions.DapperExtensions.DefaultMapper = typeof(PluralizedAutoClassMapper <>);

            LoadOneAthlete();
            LoadAthletesForPosition();
            LoadTeamWithAthletes();
            InsertAthletes();
            Console.ReadKey();
        }
Exemple #4
0
        public static void Main(string[] args)
        {
            var host = CreateHostBuilder(args).Build();

            using (var serviceScope = host.Services.CreateScope())
            {
                var ctx = serviceScope.ServiceProvider.GetRequiredService <PasswordContext>();

                ctx.Database.EnsureDeleted();
                ctx.Database.EnsureCreated();
                SeedDB.Seed(ctx);
            }

            host.Run();
        }
        public static void Main(string[] args)
        {
            try
            {
                var host = BuildWebHost(args).Build();

                using (var scope = host.Services.CreateScope())
                {
                    var services        = scope.ServiceProvider;
                    var serviceProvider = services.GetRequiredService <IServiceProvider>();
                    var contexto        = serviceProvider.GetRequiredService <ApplicationDbContext>();

                    if (contexto.Database.IsSqlServer())
                    {
                        contexto.Database.Migrate();
                    }
                    else if (contexto.Database.IsSqlite())
                    {
                        contexto.Database.EnsureCreated();
                    }

                    var carregarBancoDeExemploDaProva = services.ObtenhaBoolDasConfiguracoes(chaveCarregarBancoDeExemploDaProva);
                    if (carregarBancoDeExemploDaProva)
                    {
                        contexto.Database.ExecutaDML("DELETE FROM Agrupamentos");
                        SeedDB.Seed(serviceProvider);
                    }
                }

                host.Run();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(string.Format(ConstantesPalavras.ERRO, ex.Message));
                throw;
            }
        }
 protected override void Seed(DBContext context)
 {
     SeedDB.Seed();
 }