我将我的.NET CORE项目从2.1更新到3.1,但在Startup类中我有一些错误



我刚刚更新了我的.NET CORE版本。我已经更新了所有using,但是在添加默认标识时,方法ConfigureServices中的satrtup类中仍然存在错误。它只是给了我一个错误,说"‘ServiceCollection’不包含‘AddDefaultIdentity的定义,也没有可访问的扩展方法‘AddDefaultIdentity…’">

public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(     
Configuration.GetConnectionString("DefaultConnection")));
//ERROR
services.AddDefaultIdentity<IdentityUser>()
.AddEntityFrameworkStores<ApplicationDbContext>();
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
//SIGNAL R
services.AddSignalR();
}

我在Configure方法中也有一个错误。

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
//ERROR
app.UseDatabaseErrorPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
}
//MORE CODE
}

我应该怎么做才能解决这个错误?

这两个扩展方法已移动到单独的NuGet包中,必须在ASP.NET Core 3.0及更高版本中显式引用

方法
AddDefaultIdentity Microsoft.AspNetCore.Identity.UI
UseDatabaseErrorPage Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore

相关内容

最新更新