[英]Using ASP.NET Core IServiceCollection in ASP.NET MVC
[英]ASP.NET IserviceCollection AddIdentity not found
我有一種情況,我想將 ASP.NET 身份用戶(數據庫優先)的密碼長度更改為 4。經過大量研究,我發現我可以從 class 開始使用:
public void ConfigureServices(IServiceCollection services)
{
services.AddIdentity<ApplicationUser, IdentityRole>(options =>
{
options.Password.RequireDigit = false;
options.Password.RequiredLength = 4;
})
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
}
我已經下載了Microsoft.Framework.DependencyInjection
和Microsoft.Extensions.DependencyInjection
包,但仍然找不到 AddIdentity
AddIdentity
及其相關擴展方法是 ASP.NET Core Identity 的一部分,它位於 NuGet 包Microsoft.AspNetCore.Identity
。
AddEntityFrameworkStores
是 EntityFrameworkCore for ASP.NET Core 標識包Microsoft.AspNetCore.Identity.EntityFrameworkCore
你需要添加這個對我Miscroft.AspNetCore.Identity.UI
金塊包Miscroft.AspNetCore.Identity.UI
此外,您還必須確保為兩者選擇正確的版本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.