簡體   English   中英

“IServiceCollection”不包含“AddIdentity”的定義

[英]'IServiceCollection' does not contain a definition for 'AddIdentity'

在我在核心 5 的 web 應用程序上測試這條線之前。

services.AddIdentity<Operator, IdentityRole>().AddEntityFrameworkStores<StorageContext>().AddDefaultTokenProviders();

這在啟動 class 中工作正常。現在我想知道如何以 windows 形式實現它,Core 7。因為我剛得到這個錯誤 -

“IServiceCollection”不包含“AddIdentity”的定義,並且找不到接受“IServiceCollection”類型的第一個參數的可訪問擴展方法“AddIdentity”(是否缺少 using 指令或程序集引用?)

我缺少程序集嗎? 這些是什么? 現在這是我的代碼 -

static IHostBuilder CreateHostBuilder()
{
    return Host.CreateDefaultBuilder()
        .ConfigureServices((context, services) =>
        {
            services.AddScoped<IStorageRepository, StorageRepository>();
            services.AddDbContext<StorageContext>(option =>
            {
                option.EnableSensitiveDataLogging(true);
                option.UseSqlServer(configuration["Data:Storage:ConnectionString"]);
            });
            services.AddIdentity<Operator, IdentityRole>().AddEntityFrameworkStores<StorageContext>().AddDefaultTokenProviders();

        });
}

這個AddIdentity class 在 Winforms 中有效嗎?

只需嘗試安裝Microsoft.AspNetCore.Identity package。

我有同樣的問題,只是嘗試添加這個塊包 Microsoft.AspNetCore.Identity.UI。 我添加它,它開始看到它

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM