Scaffold Identity in "dotnet new angular" app gives error

Viewed 412

Trying to scaffold Identity in a new app, created with "dotnet new angular --auth Individual", immediately throws an error:

"There was an error running the selected code generator: 'Package restore failed. Rolling back package changes for `'aspangauth'.'

To Reproduce

Run: "dotnet new angular --auth Individual"

Open the project in Visual Studio 2019 ( I am using Version 16.9.0 Preview 2.0)

Select: Add -> New Scaffolded Item -> Identity

Either leave the "Existing layout page" box blank or enter:
~/Pages/Shared/_Layout.cshtml

[ Unlike an app created with "dotnet new webapp --auth Individual", the new SPA app does not have a _Layout.cshtml file. So I am not sure what should be entered here. But the same error occurs either way. ]

Choose some files to override. (I chose Account\Login, Account\Logout, Account\Register and Account\RegisterConfirmation. I also tried just choosing Account\Login.)

Set the Data context class to ApplicationDbContext.

Select "Add". You should immediately get the error.

Scaffold Identity works fine for me if I create an app with "dotnet new webapp --auth Individual". On stackoverflow, it was suggested to change the version of "Microsoft.VisualStudio.Web.CodeGeneration.Design". I tried changing from 5.0.1 to 5.0.0 and also 3.1.1. All gave the same error. Is there an alternate way to scaffold these files?

Besides using the VS user interface, is there a manual way of overriding the files that are needed? Can I just copy files from the ones I get when I scaffold a webapp instead of an angular app?

The document "Scaffold Identity in ASP.NET Core projects" does not contain instructions for a Asp.Net SPA project.

I created an issue for this problem in the dotnet/aspnetcore repo 3 weeks ago but no-one has reponded yet.

1 Answers

This was driving me a little mad. Finally I let it create a new dbcontext instead of specifying an existing one and everything ran successfully to completion.

Related