jasontaylordev / CleanArchitecture

Clean Architecture Solution Template for ASP.NET Core

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Scaffolding Identity UI.

Ayush2395 opened this issue · comments

Bug description
In the previous version in .NET 7, I can easily scaffold the Identity UI for customizing the UI of Login, Register, etc., But in the current release for .NET 8, its not working, its giving the error, screenshot is attached down below:

Error screenshot:

scaffold error

I tried to remove the files and other stuffs to reduce the error, but still, I get error on the AddWebService Extension method, but it reduces the errors to one, because of this extension method, I changed the namespace too, but still that error is annoying me 😂.

The error is only occurred in this .NET 8.

Please fix that my project is on hold because of that, or any idea how I can erase that error from this world 😂.

I had/have the same issue trying to scaffold the Login page. I ended having to do the following to get the scaffold to apply:

  1. Comment out every line of offending code (it was iterative)
  2. Comment out the Nswag post build event in Web.csproj

Once the item was scaffolded I reverted the changes with the following notes:

  1. It still created it's own ApplicationDbContext even though I selected one.
  2. It added some lines in Program.cs of Web project that weren't required.

In the end, I'm still receiving the following message when using the scaffolded page:
InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Identity.SignInManager-1[Microsoft.AspNetCore.Identity.IdentityUser]' while attempting to activate '<namespace>.Areas.Identity.Pages.Account.LoginModel'. Microsoft.Extensions.DependencyInjection.ActivatorUtilities.ThrowHelperUnableToResolveService(Type type, Type requiredBy)
InvalidOperationException: The exception handler configured on ExceptionHandlerOptions produced a 404 status response. This InvalidOperationException containing the original exception was thrown since this is often due to a misconfigured ExceptionHandlingPath. If the exception handler is expected to return 404 status responses then set AllowStatusCode404Response to true. Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.HandleException(HttpContext context, ExceptionDispatchInfo edi)

Just made it work here.

  1. Try to scaffold then you see this error;
  2. Go to your Directory.Packages.props and check if your using version 8.0.2 for all EntityFrameworkCore packages.
    This one was wrong =>
  3. Don't forget to use ApplicationUser in the scaffold options. The default IdentityUser shouldn't work.
  4. Delete the ApplicationDbContext from Areas/Identity/Data.
  5. Go to Program.cs and revert the changes from scaffold. That is delete the ApplicationDbContext and Identity initialization.

Can confirm it works better in 8.0.2.