public static void SeedIdentityServer(this IApplicationBuilder app, IEnumerable <Client> clients = null, IEnumerable <ApiResource> apiRessources = null, IEnumerable <IdentityResource> identityRessources = null, IEnumerable <PersistedGrant> persistedGrants = null) { var logger = app.ApplicationServices.GetService <ILogger>(); RetryPolicies.WaitAndRetryForever <Exception>( attemptDelay: TimeSpan.FromMilliseconds(5000), onRetry: (ex, timespan) => logger.LogError($"Failed to reach auth db - [{ex.Message}]"), doTry: () => { var repository = app.ApplicationServices.GetService <IRepository>(); SeedInternal(repository, clients); SeedInternal(repository, apiRessources); SeedInternal(repository, identityRessources); SeedInternal(repository, persistedGrants); } ); }