Trying to follow this guide after updating to dotnet core 3.0. Everything works well up to the scaffolding of the register/login/logout pages.
To my best knowledge I followed the previous steps as described. But when running the command
dotnet aspnet-codegenerator identity -dc WebApp1.Data.ApplicationDbContext --files "Account.Register;Account.Login;Account.Logout"
I get the error message:
It was not possible to find any compatible framework version
The specified framework Microsoft.NETCore.App, version 2.1.3 was not found.
- The following frameworks were found:
3.0.0 at [C:\dev\dotnet-sdk\share
In my csproj there are no references (direct) to 2.1.3 versions of any of the included packges.
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<UserSecretsId>aspnet-IdentityApp-XXX</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.0.0" />
</ItemGroup>
What is needed to get the aspnet-codegenerator scaffolding to run properly?
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
Try nuking the package cache: dotnet nuget locals --clear all
... rebuild the project ... then scaffold again.
... and silly ? but should ask ... you did get a good install of the 3.0 SDK, right?
"after updating to dotnet core 3.0"
Yes ... I see that you said that. Ok. Try clearing the package cache.
Tried clearing the package cache as per your suggestion and rebuilding. Still get the same error message on scaffolding.
Re "good install" - I installed the latest dotnet 3 sdk via the zip file download. But I assume everything is ok with the SDK since I can build/run the project.
Ok .... open this over at https://github.com/aspnet/Scaffolding/issues for investigation.
Thanks. I solved the issue. At some previous stage I had installed a global version of the dotnet-aspnet-codegenerator tool which needed to be updated to 3.0 to make scaffolding work.
Ah ... very good. I'm glad it had a happy ending.
Now that scaffolding is running - I get another error message that says:
Please install the following packages to your project for scaffolding identity: Microsoft.EntityFrameworkCore.SqlServer
This project uses SQLite and there should be no need for SqlServer.. Should I report this over at aspnet/scaffolding?
That was one of the packages that was removed from the App
package. The scaffolder may require it in the project. @Rick-Anderson might know. He'll be on here sometime this morning. I'll re-open the issue because if that package is required in the project, the Scaffold Identity topic doesn't say that such is the case.
... but it does say that EF Core Migrations are required. https://docs.microsoft.com/ef/core/managing-schemas/migrations/ ... and that seems likely to require that package. If the EF Core package is added, does that error message go away? Try adding ... Microsoft.EntityFrameworkCore
.
I did a dotnet add package Microsoft.EntityFrameworkCore
for my project. Still getting the same error message when running scaffolding..
Full error message for reference:
PS C:\dev\dotnet_code\IdentityApp> dotnet aspnet-codegenerator identity -dc IdentityApp.Data.ApplicationDbContext --files "Account.Register;Account.Login;Account.Logout"
Building project ...
Finding the generator 'identity'...
Running the generator 'identity'...
Please install the following packages to your project for scaffolding identity: Microsoft.EntityFrameworkCore.SqlServer
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.<BuildCommandLine>b__6_0()
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.Execute(String[] args)
at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)
Good error message. Follow the instructions.
OK, sure. Installing Microsoft.EntityFrameworkCore.SqlServer
fixes the problem. But then the need to add this package should be in the guide.. At least to me it's not obvious that you need the EFCore.SqlServer package to scaffold pages on a project using SQLite..
This was also unintuitive to me.
Moved to Moved to #16230
You shold use --useSqLite option
Thank you @dkja
Most helpful comment
OK, sure. Installing
Microsoft.EntityFrameworkCore.SqlServer
fixes the problem. But then the need to add this package should be in the guide.. At least to me it's not obvious that you need the EFCore.SqlServer package to scaffold pages on a project using SQLite..