我试图弄清楚如何使用dotnet cli工具将自定义配置文件数据添加到razor 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
答案 0 :(得分:1)
尝试以下方法:
dotnet aspnet-codegenerator identity -u WebApp1User --files "Account.Register;Account.Manage.Index"
看起来这些文档中可能有错字。您可以在此处查看更完整的说明:Scaffold Identity in ASP.NET Core projects
更新:
文档中没有错字。有关在PowerShell中收到该错误的原因,请参见下面的Chris Pratt评论。