类型“ IdentityRole”在未引用的程序集中定义

ale*_*exb 5 asp.net-core-mvc asp.net-core-2.0

当我尝试从IdentityDbContext继承asp.net core 2.0库中的dbcontext时,出现以下错误:

错误CS0012在未引用的程序集中定义了'IdentityRole'类型。您必须添加对程序集'Microsoft.Extensions.Identity.Stores,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = adb9793829ddae60'的引用。

当我尝试安装pkg时,我得到:

找不到软件包“ Microsoft.Extensions.Identity.Stores”的版本“ 2.0.0”。在第1行:char:1 +安装包Microsoft.Extensions.Identity.Stores -Version 2.0.0 + ~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + CategoryInfo:未指定:(:) [ [安装包],异常+ FullyQualifiedErrorId:NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

我已经为此转了两天。希望很快就会有解决方案...

t2t*_*t2t 3

因为我遇到了同样的问题:通过包管理器控制台将 nuget 包添加到您的项目中。

Install-Package Microsoft.Extensions.Identity.Stores -Version 2.0.2
Run Code Online (Sandbox Code Playgroud)

并选择正确的nuget包版本。