Skip to main content

arolariu.Backend.Core.Auth.Brokers

arolariu.Backend.Core.Auth​

arolariu.Backend.Core.Auth.Brokers Namespace​

Classes​

AuthDbContext Class​

Provides the Entity Framework database context for authentication and authorization data. This context manages user accounts, roles, and related security information using ASP.NET Core Identity.

public class AuthDbContext : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityDbContext<arolariu.Backend.Core.Auth.Models.AuthenticatedUser, arolariu.Backend.Core.Auth.Models.AuthenticatedUserRole, System.Guid>

Inheritance System.Object 🡒 Microsoft.EntityFrameworkCore.DbContext 🡒 Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserContext<AuthenticatedUser,System.Guid,Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>,Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>,Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>,Microsoft.AspNetCore.Identity.IdentityUserPasskey<System.Guid>> 🡒 Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityDbContext<AuthenticatedUser,AuthenticatedUserRole,System.Guid,Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>,Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>,Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>,Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>,Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>,Microsoft.AspNetCore.Identity.IdentityUserPasskey<System.Guid>> 🡒 Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityDbContext<AuthenticatedUser,AuthenticatedUserRole,System.Guid,Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>,Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>,Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>,Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>,Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>> 🡒 Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityDbContext<AuthenticatedUser,AuthenticatedUserRole,System.Guid> 🡒 AuthDbContext

Example​

// Usage in dependency injection
services.AddDbContext<AuthDbContext>(options =>
options.UseSqlServer(connectionString));

// Usage in services
public class UserService
{
private readonly AuthDbContext _context;

public UserService(AuthDbContext context)
{
_context = context;
}
}

Remarks​

This database context extends IdentityDbContext to provide: - User account management with extended profile fields - Role-based access control with custom roles - ASP.NET Core Identity integration for authentication - Guid-based primary keys for enhanced security - Support for Entity Framework migrations and schema management

Constructors​

AuthDbContext() Constructor​

Initializes a new instance of the AuthDbContext class without options. This parameterless constructor is required for Entity Framework migrations and design-time operations.

public AuthDbContext();

Remarks​

This constructor is used by: - Entity Framework migration tools during database schema generation - Design-time operations like scaffolding and reverse engineering - Testing scenarios where options are configured separately - Third-party tools that require parameterless constructors

AuthDbContext(DbContextOptions<AuthDbContext>) Constructor​

Initializes a new instance of the AuthDbContext class with the specified options. This constructor is used by dependency injection to provide database configuration.

public AuthDbContext(Microsoft.EntityFrameworkCore.DbContextOptions<arolariu.Backend.Core.Auth.Brokers.AuthDbContext> options);

Parameters​

options Microsoft.EntityFrameworkCore.DbContextOptions<AuthDbContext>

The Microsoft.EntityFrameworkCore.DbContextOptions<> containing database connection and configuration settings. These options typically include connection string, database provider, and performance settings.

Remarks​

The options parameter configures: - Database connection string and provider (SQL Server, PostgreSQL, etc.) - Connection retry policies for resilience - Performance settings like lazy loading and change tracking - Migration and schema management options

// was this page useful?