gpt4 book ai didi

c# - IdentityServer4 升级到 .NET Core 2.0 的问题(AddConfigurationStore、AddOperationalStore)

转载 作者:太空狗 更新时间:2023-10-30 00:13:49 24 4
gpt4 key购买 nike

我从 .NET Core 1.1 升级到 .NET Core 2.0 并遇到了以下问题(我还升级了一些库以支持 .net core 2.0)

CS1929 'ConfigurationStoreOptions' 不包含 'UseNpgsql' 的定义,最佳扩展方法重载 'NpgsqlDbContextOptionsExtensions.UseNpgsql(DbContextOptionsBuilder, string, Action)' 需要类型为 'DbContextOptionsBuilder' 的接收器

启动.cs

        services.AddIdentityServer()
.AddSigningCredential(Certificate.Get())
.AddAspNetIdentity<User>()
.AddConfigurationStore(builder =>
builder.UseNpgsql(connectionString, options =>
options.MigrationsAssembly(migrationsAssembly)))
.AddOperationalStore(builder =>
builder.UseNpgsql(connectionString, options =>
options.MigrationsAssembly(migrationsAssembly)));

使用 UseSqlServer 时同样的问题

// configure identity server with in-memory users, but EF stores for clients and resources
services.AddIdentityServer()
.AddTemporarySigningCredential()
.AddTestUsers(Config.GetUsers())
.AddConfigurationStore(builder =>
builder.UseSqlServer(connectionString, options =>
options.MigrationsAssembly(migrationsAssembly)))
.AddOperationalStore(builder =>
builder.UseSqlServer(connectionString, options =>
options.MigrationsAssembly(migrationsAssembly)));

http://docs.identityserver.io/en/release/quickstarts/8_entity_framework.html

注意:我添加了“使用 Microsoft.EntityFrameworkCore;”

最佳答案

解决方案:

        services.AddIdentityServer()
.AddSigningCredential(Certificate.Get())
.AddAspNetIdentity<User>()
.AddConfigurationStore(options =>
{
options.ConfigureDbContext = builder =>
builder.UseNpgsql(connectionString,
sql => sql.MigrationsAssembly(migrationsAssembly));
})
// this adds the operational data from DB (codes, tokens, consents)
.AddOperationalStore(options =>
{
options.ConfigureDbContext = builder =>
builder.UseNpgsql(connectionString,
sql => sql.MigrationsAssembly(migrationsAssembly));

// this enables automatic token cleanup. this is optional.
options.EnableTokenCleanup = true;
options.TokenCleanupInterval = 30;
});

关于c# - IdentityServer4 升级到 .NET Core 2.0 的问题(AddConfigurationStore、AddOperationalStore),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46046286/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com