IdentityServer4 升级到 .NET Core 2.0 的问题(AddConfigurationStore、AddOperationalStore)
Issue with IdentityServer4 upgrade to .NET Core 2.0 (AddConfigurationStore, AddOperationalStore)
我从 .NET Core 1.1 升级到 .NET Core 2.0 并遇到了以下问题(我还升级了一些库以支持 .net core 2.0)
CS1929 'ConfigurationStoreOptions' 不包含 'UseNpgsql' 的定义,最佳扩展方法重载 'NpgsqlDbContextOptionsExtensions.UseNpgsql(DbContextOptionsBuilder, string, Action)' 需要 'DbContextOptionsBuilder'
类型的接收器
Startup.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
注意:我已经添加了"using Microsoft.EntityFrameworkCore;"
我自己也遇到了同样的问题。 IndentityServer4.EntityFramework github 的拖网显示了一个使用 ConfigureDBContext 属性
的示例 Startup.cs
解法:
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;
});
我从 .NET Core 1.1 升级到 .NET Core 2.0 并遇到了以下问题(我还升级了一些库以支持 .net core 2.0)
CS1929 'ConfigurationStoreOptions' 不包含 'UseNpgsql' 的定义,最佳扩展方法重载 'NpgsqlDbContextOptionsExtensions.UseNpgsql(DbContextOptionsBuilder, string, Action)' 需要 'DbContextOptionsBuilder'
类型的接收器Startup.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
注意:我已经添加了"using Microsoft.EntityFrameworkCore;"
我自己也遇到了同样的问题。 IndentityServer4.EntityFramework github 的拖网显示了一个使用 ConfigureDBContext 属性
的示例 Startup.cs解法:
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;
});