CleanArchitecture icon indicating copy to clipboard operation
CleanArchitecture copied to clipboard

Scaffolding Identity UI.

Open Ayush2395 opened this issue 2 years ago • 3 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 😂.

Ayush2395 avatar Jan 16 '24 14:01 Ayush2395

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)

rlyon1 avatar Feb 02 '24 16:02 rlyon1

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 => <PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.2" />
  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.

rviveiros avatar Feb 20 '24 13:02 rviveiros

Can confirm it works better in 8.0.2.

rlyon1 avatar Mar 11 '24 13:03 rlyon1