Esempio n. 1
0
        public static void Main(string[] args)
        {
            var host = CreateWebHostBuilder(args).Build();

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

                // Create/Seed the database
                Seeds.SeedDatabase(services);

                // Create the roles for the application
                var serviceProvider = services.GetRequiredService <IServiceProvider>();
                var configuration   = services.GetRequiredService <IConfiguration>();
                Seeds.CreateRoles(serviceProvider).Wait();
            }

            host.Run();
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            var host = CreateWebHostBuilder(args).Build();

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

                // Create/Seed the database
                Seeds.SeedDatabase(services);

                // Create the roles for the application
                var serviceProvider = services.GetRequiredService <IServiceProvider>();
                var configuration   = services.GetRequiredService <IConfiguration>();
                Seeds.CreateRoles(serviceProvider, configuration).Wait();

                AppDbContext context = services.GetRequiredService <AppDbContext>();

                // Only take this into account when working with existing databases
                // context.Database.Migrate();
            }

            host.Run();
        }