Walking through this tutorial Scaffold Identity in ASP.NET Core projects.
I did everything as written, so here are the steps to reproduce:
Create a .net core project (named "DotNetCorePlayGround" with vs 2019).
From the package manager console run this commands:
dotnet tool install -g dotnet-aspnet-codegenerator
And:
dotnet add dotnetcoreplayground package Microsoft.VisualStudio.Web.CodeGeneration.Design
dotnet add dotnetcoreplayground package Microsoft.EntityFrameworkCore.Design
dotnet add dotnetcoreplayground package Microsoft.AspNetCore.Identity.EntityFrameworkCore
dotnet add dotnetcoreplayground package Microsoft.AspNetCore.Identity.UI
dotnet add dotnetcoreplayground package Microsoft.EntityFrameworkCore.SqlServer
dotnet add dotnetcoreplayground package Microsoft.EntityFrameworkCore.Tools
And everything worked as expected and the resulted is:
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.1.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.8" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.2" />
</ItemGroup>
The problem is with this line (only trying to list the Identity scaffolder options):
dotnet aspnet-codegenerator identity -h
The result is:
dotnet : Scaffolding failed.
At line:1 char:1
+ dotnet aspnet-codegenerator identity -h p C:\Users\[user]\sou ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Scaffolding failed.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Could not find project file in C:\Users\[user]\source\repos\DotnetCoreplayGround
Any idea why it can not find the project file?
I tried to run:
dotnet aspnet-codegenerator -help
and got Scaffolding failed error.
Problem was that my .config
folder was deleted ( I do not why)...
How I solved the problem:
I create a new .config
folder and a new dotnet-tools.json
file in there.
Content of the file:
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "3.1.3",
"commands": [
"dotnet-ef"
]
},
"dotnet-aspnet-codegenerator": {
"version": "3.1.1",
"commands": [
"dotnet-aspnet-codegenerator"
]
}
}
}
Then go to terminal and run dotnet tool restore.
And that's it!