Course contentsShow
← C#
Lesson 1174 of 1,90811. Identity, Security, and ClaimsFree lesson

Understanding the ASP.NET Core Identity Architecture

Explain the high-level components of Identity including users, roles, and the underlying data store.

In this lesson, you will learn how ASP.NET Core Identity acts as a modular framework to manage authentication, authorization, and user data within your application.

The Core Identity Architecture

At its heart, ASP.NET Core Identity is a collection of services designed to handle the "who" and "what" of your application. Instead of reinventing user registration or password hashing, you leverage a robust system that maps your application's security requirements to a database backend.

Key Components

The architecture is built on three primary pillars:

  1. Users (IdentityUser): This represents the actual account holder. By default, it stores properties like UserName, Email, and a hashed PasswordHash. You can extend this by inheriting from IdentityUser to add custom fields like DateOfBirth or ProfilePictureUrl.
  2. Roles (IdentityRole): This provides a mechanism for grouping users to simplify authorization. Instead of assigning permissions to individual users, you assign them to a role (e.g., "Admin" or "Editor"), and the user inherits those privileges.
  3. The Data Store (Entity Framework Core): Identity uses UserManager<TUser> and RoleManager<TRole> to interact with the underlying database. These managers act as the "gatekeepers," communicating with your database context (which must inherit from IdentityDbContext) to perform CRUD operations on your users and roles.

How They Connect

When you register Identity in your Program.cs, you are wiring up these managers to your database:

builder.Services.AddDefaultIdentity<IdentityUser>()
    .AddRoles<IdentityRole>()
    .AddEntityFrameworkStores<ApplicationDbContext>();

When you call userManager.CreateAsync(user, password), the Identity system automatically handles salting and hashing the password before sending it to the database through your ApplicationDbContext. This abstraction layer allows you to focus on application logic while the framework manages the complex security storage patterns. By keeping these components separate, the architecture remains highly extensible—you can swap the underlying storage provider or customize the user model without breaking your application’s security flow.

Key Takeaway: ASP.NET Core Identity provides a managed, extensible architecture that bridges your user model, role-based authorization, and persistent storage through specialized managers.