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

            using (var scope = host.Services.CreateScope())
            {
                var petFoodContext = scope.ServiceProvider.GetRequiredService <PetFoodContext>();
                await PetFoodContextSeed.SeedAsync(petFoodContext);
            }
            host.Run();
        }
Ejemplo n.º 2
0
        public static async Task Main(string[] args)
        {
            var host = CreateHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var appIdentityDbContext = scope.ServiceProvider.GetRequiredService <AppIdentityDbContext>();
                var petFoodContext       = scope.ServiceProvider.GetRequiredService <PetFoodContext>();

                // create database if not exists
                await appIdentityDbContext.Database.EnsureCreatedAsync();

                await petFoodContext.Database.EnsureCreatedAsync();

                await PetFoodContextSeed.SeedAsync(petFoodContext);
            }

            host.Run();
        }