我想得到这样的数据:
var persistedGrants = await _PersistedGrantDbContext.PersistedGrants.ToListAsync();这是我的配置:
services.AddDbContext<AccountDbContext>(options =>
options.UseSqlServer(connectionString,
sql => sql.MigrationsAssembly(migrationsAssembly)))
.AddDbContext<PersistedGrantDbContext>(options =>
options.UseSqlServer(connectionString,
sql => sql.MigrationsAssembly(migrationsAssembly)));但我有个错误:
处理请求时发生了未处理的异常。'IdentityServer4.EntityFramework.Options.OperationalStoreOptions‘:在尝试激活'IdentityServer4.EntityFramework.DbContexts.PersistedGrantDbContext'.时无法解析’IdentityServer4.EntityFramework.DbContexts.PersistedGrantDbContext‘.类型的服务
我该怎么做才能修好?
发布于 2020-02-05 02:39:34
是的,我解决了我的问题。我很想念services.AddIdentityServer().AddOperationalStore
发布于 2020-02-04 11:24:12
没有必要直接调用数据库,而是使用所提供的存储。
在这种情况下,您可以使用IPersistedGrantStore
public class MyClass
{
private readonly IPersistedGrantStore _store;
public MyClass(IPersistedGrantStore store)
{
_store = store;
}
public async Task Something(string sub)
{
var persistedGrants = await _store.GetAllAsync(sub);
}
}https://stackoverflow.com/questions/60055581
复制相似问题