[英]IserviceCollection does not contain defination of “AddDefaultIdentity”
AddDefaultIdentity
拋出錯誤
'IServiceCollection' does not contain a definition for 'AddDefaultIdentity' and
no accessible extension method 'AddDefaultIdentity' accepting a first argument
of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?)
IServiceCollection
中不存在WebApiDotNet.AddDefaultIdentity
“IServiceCollection”不包含“AddDefaultIdentity”的定義,並且找不到接受“IServiceCollection”類型的第一個參數的可訪問擴展方法“AddDefaultIdentity”(您是否缺少 using 指令或程序集引用?)
當我在 3.0 項目中安裝高於 3.0 版的Microsoft.AspNetCore.Identity.UI
package 時,我重現了該問題。 注意: AddDefaultIdentity
擴展方法用於為 Razor Pages 和 MVC 添加默認 UI 服務。
您可以使用AddIdentity
而不是AddDefaultIdentity
,如下所示:
services.AddIdentity<ApplicationUser,IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>();
如果要使用AddDefaultIdentity
,則應將Microsoft.AspNetCore.Identity.UI
的版本更新為 3.0。
AddDefaultIdentity和AddIdentity的區別參考https://medium.com/@xsoheilalizadeh/asp-net-core-identity-deep-dive-stores-e0e54291b51d
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.