Пример #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();
        }
Пример #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();
        }