Search code examples
c#asp.net.netasp.net-coreidentityserver4

How to use PersistedGrantDbContext to select PersistedGrant


I want to get data like this:

var persistedGrants = await _PersistedGrantDbContext.PersistedGrants.ToListAsync();

This is my config:

services.AddDbContext<AccountDbContext>(options =>
                        options.UseSqlServer(connectionString,
                            sql => sql.MigrationsAssembly(migrationsAssembly)))
                    .AddDbContext<PersistedGrantDbContext>(options =>
                        options.UseSqlServer(connectionString,
                            sql => sql.MigrationsAssembly(migrationsAssembly)));

But I have a mistake:

An unhandled exception occurred while processing the request. InvalidOperationException: Unable to resolve service for type 'IdentityServer4.EntityFramework.Options.OperationalStoreOptions' while attempting to activate 'IdentityServer4.EntityFramework.DbContexts.PersistedGrantDbContext'.

What should I go to fix it?


Solution

  • Yeah I have resolved my problem. I was missed services.AddIdentityServer().AddOperationalStore