c# - 在添加身份对话框中禁用用户类条目
问题描述
我正在尝试搭建一些身份页面。但是,虽然我可以选择要覆盖的文件并选择我的数据库上下文类,但选择我的用户类的框被禁用。
并且尝试在不设置用户类的情况下添加脚手架会产生错误。
运行所选代码生成器时出错:
'包还原失败。回滚“Railtrax”的包更改。
这个脚手架功能对我来说大约 90% 的时间都失败了。我不知道为什么它不能变得更可靠。
请注意,我确实定义了我的用户类。
public class ApplicationUser : IdentityUser
{
// ...
}
我在我的数据库上下文类中引用它。
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
// ...
}
所以我不明白为什么它不起作用。谁能看到我可能缺少的东西?
解决方案
我遇到了这个错误,不得不将身份 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" />
推荐阅读
- html - Chrome/Android/Google 未更新对我网站的更改。它是否缓存在外部服务器上?
- python - 我无法在 macOS 上安装 mysqlclient
- python - 列表中相邻元素的所有可能组合
- firebase - Flutter FutureBuilder返回空错误
- javascript - Webhook 请求中的 IFTTT 身份验证
- c++ - 增量速度是否受时钟速率影响
- r - UseMethod(“filter_”)中的错误:没有适用于“filter_”的方法应用于“function”类的对象
- python - PyInstaller ImportError:无法从“docx”导入名称“文档”
- c# - 用户电子邮件 ID 显示为空
- python - Python:试图从控制台获取数据