Beispiel #1
0
 public static async Task EnsureDataSeeded(IServiceProvider serviceProvider)
 {
     using (var scope = serviceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope())
     {
         var context = scope.ServiceProvider.GetRequiredService <ApplicationDbContext>();
         var seeder  = new Seeder(context);
         await seeder.Seed();
     }
 }
Beispiel #2
0
        public static void Main(string[] args)
        {
            var host = CreateWebHostBuilder(args).Build();

            if (args.Contains("--seed"))
            {
                Seeder.EnsureDataSeeded(host.Services).GetAwaiter().GetResult();
            }
            host.Run();
        }