Beispiel #1
0
        public static void Main(string[] args)
        {
            var host = CreateHostBuilder(args)
                       .ConfigureAppConfiguration((hostContext, builder) =>
            {
                if (hostContext.HostingEnvironment.IsDevelopment())
                {
                    builder.AddUserSecrets <Program>( );
                }
            })
                       .Build( );

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

                try
                {
                    AppDbSeed.SeedSampleData(services);
                }
                catch (Exception ex)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >( );
                    logger.LogError(ex, "Error while seeding the db.");
                }
            }



            host.Run();
        }
Beispiel #2
0
        public static void Main(string[] args)
        {
            var host = CreateHostBuilder(args).Build( );

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

                try
                {
                    AppDbSeed.SeedSampleData(services);
                }
                catch (Exception ex)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >( );
                    logger.LogError(ex, "Error while seeding the db.");
                }
            }



            host.Run( );
        }