How to Scaffold or Generate a Custom Identity Login UI in Asp.Net Core 3.1

How to Scaffold or Generate a Custom Identity Login UI in Asp.Net Core 3.1

Click to Watch Video

How to Scaffold or Generate a Custom Identity Login UI in Asp.Net Core 3.1

1. Right Click on your project name and Click "Add"
How to generate Identity Login UI

Visual Studio 2019 will attempt to generate Identity Pages provided their are no errors
How to generate Identity Login UI Final Step
- When Visual Studio Completes Scaffolding the Area pages, you will see the folder populated with pages
Generating custom login pages in asp.net core 3.1
-[NB] After generating the Identity pages, there might be errors to resolve, if you have a construting classes called User or Users in your application you might need to refactor code by creating a seperate User Class and registering that class an a dependency in a DI Container in Asp.Net Core 3.1 Startup.cs.


services.AddIdentity<AspNetUsers,IdentityRole>(options => options.Sign.RequireConfirmationAccount = true).AddEntityFrameworkStores().AddDefaultTokenProviders().AdddefaultUI();

After registering the AspNetUser Class with Dependency Injection in Startup Class, you will have to create a DbSet property in ApplicationDbContext Class to be able to Set or Get using AspNetUser Class in the Application.
Generating custom login pages in asp.net core 3.1

 

- If you used AspNetUser Class as your primary Identity User Class, then you will have to add a Key Data Annotation in the AspNetUser Class Modal to be able to use Entity Framework without throwing an error. This is important because during insertion of Data and Retrieval the primary Key has to be present that would act as an Index.

In addition, the AspNetUser partial class has to inherit IdentityUser class to be used as a primary User Class.

Generating custom login pages in asp.net core 3.1 Adding Primary Key


Edit this Article
Asp.Net Core 3.1 Scaffold Identity UI Technology published
Was this page helpful?
Yes Yes! this solution to the problem was helpful. No No! this solution to the problem was not helpful.. Leave ErnesTech Feedback.Feedback
If you log in, you will be notified when someone leaves a comment.

Other users would like to know if this solution helped you.
Your Session is Ending
Login to Continue


© 2021 - ErnesTech - Privacy