jasontaylordev / CleanArchitecture

Clean Architecture Solution Template for ASP.NET Core

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Scaffold shows "Failed to compile the project in memory" error

fbaham opened this issue · comments

When I add Identity Scaffold Element, the editor shows an error.

To Reproduce
Steps to reproduce the behavior:

  1. dotnet new ca-sln --client-framework Angular --output YourProjectName
  2. In the Visual Studio Add new Scaffold element
  3. Select Identity Scaffold element
  4. Mark "replace all files"
  5. Select ApplicationDbContext and press "Add"
  6. See the error.

I want to edit the Login page, and quit the registration page.
Thanks.

Screenshots
image

  1. On the web project, in the endpoints folder, comment the lines below the .RequireAuthorization() in the override Map method for all the endpoints.
  2. Web project, Infrastructure folder, static class IEndpointRouteBuilderExtensions, comment all lines with Guard.Against.AnonymousMethod(handler);
  3. web project, Infrastructure folder, static class MethodInfoExtensions, static void AnonymousMethod, comment this line: if (input.Method.IsAnonymous())
  4. web project, Program.cs, comment lines: builder.Services.AddKeyVaultIfConfigured(builder.Configuration); and builder.Services.AddWebServices();
  5. web project, static class DependencyInjection, copy all the services from IServiceCollection AddWebServices() method and paste it in Program.cs, replace "services." by "builder.Services."
  6. Try scaffolding again.
  7. 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)
  8. web project, Program.cs, remove newly added dbContext connection.
  9. Before testing, revert back the changes from step 1 to 5.
    It worked for me.
  1. On the web project, in the endpoints folder, comment the lines below the .RequireAuthorization() in the override Map method for all the endpoints.
  2. Web project, Infrastructure folder, static class IEndpointRouteBuilderExtensions, comment all lines with Guard.Against.AnonymousMethod(handler);
  3. web project, Infrastructure folder, static class MethodInfoExtensions, static void AnonymousMethod, comment this line: if (input.Method.IsAnonymous())
  4. web project, Program.cs, comment lines: builder.Services.AddKeyVaultIfConfigured(builder.Configuration); and builder.Services.AddWebServices();
  5. web project, static class DependencyInjection, copy all the services from IServiceCollection AddWebServices() method and paste it in Program.cs, replace "services." by "builder.Services."
  6. Try scaffolding again.
  7. 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)
  8. web project, Program.cs, remove newly added dbContext connection.
  9. 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.