c# - 无法将自定义用户数据添加到脚手架 ASP.NET Core 项目
问题描述
我试图弄清楚如何使用 dotnet cli 工具将自定义配置文件数据添加到剃须刀网络应用程序中。此 Web 应用程序针对 dotnet core 3.0 sdk。但是,当我尝试运行代码生成器工具时,我一直遇到错误。
我已经恢复了我在错误消息中看到的所有包,但这还不够。
这些是我添加到项目中的包。
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.0.0" />
</ItemGroup>
预期的结果是让应用程序告诉我它工作正常并创建文件。相反,我在控制台中不断收到此错误。
Account.Manage.Index : The term 'Account.Manage.Index' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:74
+ ... tor identity -u WebApp1User -fi Account.Register;Account.Manage.Index
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Account.Manage.Index:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
除了注册之外,我没有索引页面或任何其他主要页面。奇怪的是,我的用户和数据库上下文确实生成了。我很困惑为什么会这样。该网站上的说明没有提及它。https://docs.microsoft.com/en-us/aspnet/core/security/authentication/add-user-data?view=aspnetcore-3.0&tabs=netcore-cli
解决方案
试试这个:
dotnet aspnet-codegenerator identity -u WebApp1User --files "Account.Register;Account.Manage.Index"
看起来这些文档中可能有错字。您可以在此处查看更完整的说明:ASP.NET Core 项目中的脚手架标识
更新:
文档中没有错字。请参阅下面Chris Pratt的评论,了解您在 PowerShell 中遇到该错误的原因。
推荐阅读
- apache-kafka - 如何使用 Spring Reactive Kafka 实现重试和恢复逻辑
- firebase - 如何用2个数据进行查询?
- python - 在 Python 中反转 .ico 文件
- reactjs - 如何防止 VSCode 在 React 中多行传播信息?(格式)
- php - 在 Vue 中使用 PHP Api 响应
- reactjs - Expo React 警告:无法对未安装的组件执行 React 状态更新。这是一个无操作,但它表明您的应用程序中存在内存泄漏
- powerapps - 我正在尝试将查找功能结果转换为 powerapps 中的文本
- swift - 带有firestore数组的tableview swift uikit
- python - 将水加到一堆玻璃杯中
- python - 使用 StringGrouper 将分组数据解析为 json