首页 > 解决方案 > 在添加身份对话框中禁用用户类条目

问题描述

我正在尝试搭建一些身份页面。但是,虽然我可以选择要覆盖的文件并选择我的数据库上下文类,但选择我的用户类的框被禁用。

添加身份对话框

并且尝试在不设置用户类的情况下添加脚手架会产生错误。

运行所选代码生成器时出错:

'包还原失败。回滚“Railtrax”的包更改。

这个脚手架功能对我来说大约 90% 的时间都失败了。我不知道为什么它不能变得更可靠。

请注意,我确实定义了我的用户类。

public class ApplicationUser : IdentityUser
{
    // ...
}

我在我的数据库上下文类中引用它。

public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
    // ...
}

所以我不明白为什么它不起作用。谁能看到我可能缺少的东西?

标签: c#asp.netasp.net-identityrazor-pagesasp.net5

解决方案


我遇到了这个错误,不得不将身份 Microsoft.AspNetCore.Identity.UI 恢复到旧版本

所以它在 csproj 中看起来像这样

          <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.2" />
            <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.2" />
            <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.2">
    
     
        <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.6" />
        <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="5.0.6" />
       
        <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.7">
  </PackageReference>
        <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.6" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.6">
          <PrivateAssets>all</PrivateAssets>
          <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
        </PackageReference>
        <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" />

推荐阅读