Scaffold shows "Failed to compile the project in memory" error
fbaham opened this issue · comments
Francisco Bahamondes commented
When I add Identity Scaffold Element, the editor shows an error.
To Reproduce
Steps to reproduce the behavior:
- dotnet new ca-sln --client-framework Angular --output YourProjectName
- In the Visual Studio Add new Scaffold element
- Select Identity Scaffold element
- Mark "replace all files"
- Select ApplicationDbContext and press "Add"
- See the error.
I want to edit the Login page, and quit the registration page.
Thanks.
Luiz Guilherme Pereira commented
- On the web project, in the endpoints folder, comment the lines below the .RequireAuthorization() in the override Map method for all the endpoints.
- Web project, Infrastructure folder, static class IEndpointRouteBuilderExtensions, comment all lines with Guard.Against.AnonymousMethod(handler);
- web project, Infrastructure folder, static class MethodInfoExtensions, static void AnonymousMethod, comment this line: if (input.Method.IsAnonymous())
- web project, Program.cs, comment lines: builder.Services.AddKeyVaultIfConfigured(builder.Configuration); and builder.Services.AddWebServices();
- web project, static class DependencyInjection, copy all the services from IServiceCollection AddWebServices() method and paste it in Program.cs, replace "services." by "builder.Services."
- Try scaffolding again.
- If successful, web project/Areas/Identity/Pages/Account -> check the .cs files to replace "IdentityUser" by "ApplicationUser" and also change it on page _ManageNav.cshtml (@Inject SignInManager"ApplicationUser" SignInManager)
- web project, Program.cs, remove newly added dbContext connection.
- Before testing, revert back the changes from step 1 to 5.
It worked for me.
Francisco Bahamondes commented
- On the web project, in the endpoints folder, comment the lines below the .RequireAuthorization() in the override Map method for all the endpoints.
- Web project, Infrastructure folder, static class IEndpointRouteBuilderExtensions, comment all lines with Guard.Against.AnonymousMethod(handler);
- web project, Infrastructure folder, static class MethodInfoExtensions, static void AnonymousMethod, comment this line: if (input.Method.IsAnonymous())
- web project, Program.cs, comment lines: builder.Services.AddKeyVaultIfConfigured(builder.Configuration); and builder.Services.AddWebServices();
- web project, static class DependencyInjection, copy all the services from IServiceCollection AddWebServices() method and paste it in Program.cs, replace "services." by "builder.Services."
- Try scaffolding again.
- If successful, web project/Areas/Identity/Pages/Account -> check the .cs files to replace "IdentityUser" by "ApplicationUser" and also change it on page _ManageNav.cshtml (@Inject SignInManager"ApplicationUser" SignInManager)
- web project, Program.cs, remove newly added dbContext connection.
- Before testing, revert back the changes from step 1 to 5.
It worked for me.
I did all the steps and it worked, thank you very much.