private async Task InitializeGrantStoreAndConfiguration(IApplicationBuilder app)
        {
            //callbacks urls from config:
            var clientUrls = new Dictionary <string, string>();

            clientUrls.Add("Angular", Configuration.GetValue <string>("Urls:Angular"));

            using (var serviceScope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope())
            {
                serviceScope.ServiceProvider.GetRequiredService <PersistedGrantDbContext>().Database.Migrate();
                var context = serviceScope.ServiceProvider.GetRequiredService <ConfigurationDbContext>();
                context.Database.Migrate();

                if (!context.Clients.Any())
                {
                    foreach (var client in IdentityServerConfig.GetClients(clientUrls))
                    {
                        await context.Clients.AddAsync(client.ToEntity());
                    }
                    await context.SaveChangesAsync();
                }

                if (!context.IdentityResources.Any())
                {
                    foreach (var resource in IdentityServerConfig.GetResources())
                    {
                        await context.IdentityResources.AddAsync(resource.ToEntity());
                    }
                    await context.SaveChangesAsync();
                }

                if (!context.ApiResources.Any())
                {
                    foreach (var api in IdentityServerConfig.GetApis())
                    {
                        await context.ApiResources.AddAsync(api.ToEntity());
                    }
                    await context.SaveChangesAsync();
                }
            }
        }