title: Use of ConfigurationDbContext in IndetityServer4 from different API's
body: <p>After solving my initial problem with adding UserManager to an API (<a href="https://stackoverflow.com/questions/54493921/user-creation-with-identityserver4-from-multiple-apis/54515377?noredirect=1#comment95863315_54515377">User creation with IdentityServer4 from multiple API&#39;s</a>) that does not initialize IdentityServer4  (which in turn is initialized inside a web app only responsible for registration and login of users) I have run to another problem. From the same API I wish to also get the Clients and Resources from the IConfigurationDbContext of IdentityServer4.</p>
  
  <p>What I am trying so far is the following: 
  I am adding the ConfigurationDbContext in the startup of the API and then through the ClientsController and ClientsRepository I am trying to access the clients as shown below.</p>
  
  <p><em>Startup.cs</em></p>
  
  <pre><code> services.AddDbContext&lt;ApplicationDbContext&gt;(options =&gt;
          options.UseNpgsql(defaultConnection, db =&gt; db.MigrationsAssembly("XXXXXXX"))
      );
  
   services.AddDbContext&lt;ConfigurationDbContext&gt;(options =&gt;
          options.UseNpgsql(defaultConnection, db =&gt; db.MigrationsAssembly("XXXXXXXX"))
      );
  
    services.AddIdentityCore&lt;ApplicationUser&gt;(options =&gt; {
          options.Password.RequireNonAlphanumeric = false;
      });
      new IdentityBuilder(typeof(ApplicationUser), typeof(IdentityRole), services)
          .AddRoleManager&lt;RoleManager&lt;IdentityRole&gt;&gt;()
          .AddSignInManager&lt;SignInManager&lt;ApplicationUser&gt;&gt;()
          .AddEntityFrameworkStores&lt;ApplicationDbContext&gt;();
  </code></pre>
  
  <p><em>ClientsRepository.cs</em> (in .DataAccess):</p>
  
  <pre><code>private readonly IConfigurationDbContext _context;
  public bool AutoSaveChanges { get; set; } = true;
  
  public ClientRepository(IConfigurationDbContext context)
  {
      _context = context;
  }
  
  public Task&lt;Client&gt; GetClientAsync(int id)
  {
      return _context.Clients
          .Include(x =&gt; x.AllowedGrantTypes)
          .Include(x =&gt; x.RedirectUris)
          .Include(x =&gt; x.PostLogoutRedirectUris)
          .Include(x =&gt; x.AllowedScopes)
          .Include(x =&gt; x.ClientSecrets)
          .Include(x =&gt; x.Claims)
          .Include(x =&gt; x.IdentityProviderRestrictions)
          .Include(x =&gt; x.AllowedCorsOrigins)
          .Include(x =&gt; x.Properties)
          .Where(x =&gt; x.Id == id)
              .SingleOrDefaultAsync();
   }
  </code></pre>
  
  <p>However, I am getting the following error:</p>
  
  <pre><code>System.InvalidOperationException: Unable to resolve service for type 'IdentityServer4.EntityFramework.Interfaces.IConfigurationDbContext' while attempting to activate 'XXXXXX.Data.Repositories.ClientRepository'. 
  </code></pre>
  
  <p>I am guessing it has again to do something with the services Startup, but I cannot seem to find it.</p>
  
  <p>Has anyone solved something similar?</p>
  
  <p>Best,
  Marios.</p>