Exemplo n.º 1
0
        public static void SeedDatabase(this IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                Log.Information("*** Seeding database with data ***");

                // seed database with data
                using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope())
                {
                    var dbContext = serviceScope.ServiceProvider.GetService <DemoDbContext>();
                    DatabaseInitializer.AddDatabaseSeedData(dbContext);
                }
            }
        }