我需要帮助的人我正在一个新的项目中,我正在实现身份服务器4,我正在尝试使用我的数据库中的asp.Identity来恢复以前创建的用户,以便能够验证我何时从外部登录身份服务器4.抱歉我的英文.我的Startup.cs
public class Startup
{
public IConfiguration Configuration { get; }
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public void ConfigureServices(IServiceCollection services)
{
#region --Identity ASP
services.AddDbContext<QGoodDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")),ServiceLifetime.Transient);
services.AddIdentity<ApplicationUser, ApplicationRole>()
.AddEntityFrameworkStores<QGoodDbContext>()
.AddDefaultTokenProviders();
#endregion
services.AddMvc();
services.AddScoped<UserManager<ApplicationUser>>();
services.AddScoped<SignInManager<ApplicationUser>>();
// configure identity server with in-memory stores, keys, clients and scopes
services.AddIdentityServer()
.AddDeveloperSigningCredential()
.AddInMemoryPersistedGrants()
.AddInMemoryIdentityResources(Config.GetIdentityResources())
.AddInMemoryApiResources(Config.GetApiResources())
.AddInMemoryClients(Config.GetClients());
//.AddAspNetIdentity<ApplicationUser>();
}
}
Run Code Online (Sandbox Code Playgroud)
当我初始化我的数据库时,我已经有这个错误
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseIdentityServer();
app.UseStaticFiles();
app.UseMvcWithDefaultRoute();
InitializeDatabase(app);
}
private void InitializeDatabase(IApplicationBuilder app) …Run Code Online (Sandbox Code Playgroud)