For simple and easy authentication, you can use the aspnet-codegenerator tool. For that, you should first install dependencies such as the identity framework:
dotnet add package Microsoft.AspNetCore.Identity.EntityFrameworkCore
and the aspnet-codegenerator tool itself:
dotnet tool install -g dotnet-aspnet-codegenerator
and then install the dependencies for working with your desired database, e.g., SQL Server.
Then you configure the Identity:
builder.Services.AddDefaultIdentity<IdentityUser>(options =>
{
options.SignIn.RequireConfirmedAccount = false;
})
.AddEntityFrameworkStores<ApplicationDbContext>();
Then in the root folder of your project, run this CLI command:
dotnet aspnet-codegenerator identity -dc ApplicationDbContext
Now the tool adds identity pages automatically for you, and you can use that in your project.