Example #1
0
        public static IApplicationBuilder SeedDatabase(this IApplicationBuilder app, IConfiguration configuration)
        {
            using (var serviceScope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope())
            {
                var userManager = serviceScope.ServiceProvider.GetRequiredService <UserManager <ApplicationUser> >();
                var roleManager = serviceScope.ServiceProvider.GetRequiredService <RoleManager <IdentityRole> >();
                var store       = serviceScope.ServiceProvider.GetRequiredService <IDocumentStore>();
                var logger      = serviceScope.ServiceProvider.GetRequiredService <ILogger <SynchronizationManager> >();

                var synchronizationManager = new SynchronizationManager(userManager, roleManager, store, logger);
                synchronizationManager.SynchonizeAdminUserAsync().Wait();
                synchronizationManager.SynchronizeConfigurationAsync(configuration).Wait();

                var compatiabilityManager = new CompatiabilityManager(serviceScope);
                compatiabilityManager.FixInvalidScopesFollowingIdentityServerPackageUpgrade().Wait();
            }

            return(app);
        }