我正在尝试弄清楚如何使用 dotnet cli 工具将自定义配置文件数据添加到 razor Web 应用程序中。此 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://learn.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"
看起来这些文档中可能存在拼写错误。您可以在此处查看更完整的说明:Scaffold Identity in ASP.NET Core projects
更新:
文档中没有拼写错误。请参阅Chris Pratt请参阅下面的评论,了解您在 PowerShell 中收到该错误的原因。
关于c# - 无法将自定义用户数据添加到搭建的 ASP.NET Core 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58242623/