예제 #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();
        }
예제 #2
0
파일: Program.cs 프로젝트: yigith/PetFood
        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();
        }