MasLazu.AspNet.Authentication.Core.EfCore
1.0.0-preview.10
This is a prerelease version of MasLazu.AspNet.Authentication.Core.EfCore.
dotnet add package MasLazu.AspNet.Authentication.Core.EfCore --version 1.0.0-preview.10
NuGet\Install-Package MasLazu.AspNet.Authentication.Core.EfCore -Version 1.0.0-preview.10
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MasLazu.AspNet.Authentication.Core.EfCore" Version="1.0.0-preview.10" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MasLazu.AspNet.Authentication.Core.EfCore" Version="1.0.0-preview.10" />
<PackageReference Include="MasLazu.AspNet.Authentication.Core.EfCore" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MasLazu.AspNet.Authentication.Core.EfCore --version 1.0.0-preview.10
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MasLazu.AspNet.Authentication.Core.EfCore, 1.0.0-preview.10"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MasLazu.AspNet.Authentication.Core.EfCore@1.0.0-preview.10
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MasLazu.AspNet.Authentication.Core.EfCore&version=1.0.0-preview.10&prerelease
#tool nuget:?package=MasLazu.AspNet.Authentication.Core.EfCore&version=1.0.0-preview.10&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
MasLazu.AspNet.Authentication.Core.EfCore
This project contains the Entity Framework Core configuration for the MasLazu ASP.NET Authentication Core library.
Overview
The MasLazu.AspNet.Authentication.Core.EfCore project provides:
- Entity Configurations: EF Core mappings for all domain entities
- DbContext Classes: Database contexts for write and read operations
- Database Mappings: Table structures, relationships, and constraints
- CQRS Support: Separate read and write contexts
DbContext Classes
AuthenticationCoreDbContext (Write Context)
- Extends
BaseDbContextfor write operations - Includes all entities: Users, RefreshTokens, LoginMethods, etc.
- Applies entity configurations from the assembly
- Used for create, update, delete operations
AuthenticationCoreReadDbContext (Read Context)
- Extends
BaseReadDbContextfor read operations - Includes read-optimized entity sets
- Supports CQRS pattern for query separation
- Used for read-only operations
Entity Configurations
Core Entity Configurations
- UserConfiguration: User entity mapping with relationships and indexes
- LoginMethodConfiguration: Login method with unique code constraint
- UserLoginMethodConfiguration: Junction table for user-login method relationships
- RefreshTokenConfiguration: Refresh token storage configuration
- UserRefreshTokenConfiguration: User-refresh token relationships
Reference Data Configurations
- GenderConfiguration: Gender reference data
- LanguageConfiguration: Language reference data
- TimezoneConfiguration: Timezone with offset information
Database Schema
Key Tables
- Users: User accounts with profile information
- LoginMethods: Available authentication methods
- UserLoginMethods: User-authentication method associations
- RefreshTokens: JWT refresh token storage
- UserRefreshTokens: User-refresh token relationships
- Genders: Gender reference data
- Languages: Language reference data
- Timezones: Timezone reference data
Relationships
Users
├── FK → Genders (GenderCode)
├── FK → Languages (LanguageCode)
├── FK → Timezones (TimezoneId)
└── 1:N → UserLoginMethods
└── FK → LoginMethods (LoginMethodCode)
Users
└── 1:N → UserRefreshTokens
└── FK → RefreshTokens (RefreshTokenId)
Project Configuration
- Target Framework: .NET 9.0
- Implicit Usings: Enabled
- Nullable Reference Types: Enabled
Dependencies
Package References:
MasLazu.AspNet.Framework.EfCore- Base EF Core framework
Project References:
MasLazu.AspNet.Authentication.Core.Domain- Domain entities
Usage
Register the DbContexts in your application's DI container:
services.AddDbContext<AuthenticationCoreDbContext>(options =>
options.UseSqlServer(connectionString));
services.AddDbContext<AuthenticationCoreReadDbContext>(options =>
options.UseSqlServer(connectionString));
For CQRS setup:
// Write context for commands
services.AddScoped<AuthenticationCoreDbContext>();
// Read context for queries
services.AddScoped<AuthenticationCoreReadDbContext>();
Migration Strategy
Create and apply migrations:
dotnet ef migrations add InitialCreate --project src/MasLazu.AspNet.Authentication.Core.EfCore --startup-project YourStartupProject
dotnet ef database update --project src/MasLazu.AspNet.Authentication.Core.EfCore --startup-project YourStartupProject
Performance Considerations
- Indexes: Strategic indexes on frequently queried columns (Email, Username, PhoneNumber)
- Relationships: Proper foreign key constraints and cascade behaviors
- Read Optimization: Separate read context for query performance
- Connection Management: Proper connection pooling and lifetime management
🛠️ Development Guidelines
Naming Conventions
- Configurations: Suffix with Configuration (e.g., UserConfiguration)
- DbContexts: Suffix with DbContext (e.g., AuthenticationCoreDbContext)
- Extensions: Suffix with Extensions (e.g., ServiceCollectionExtensions)
- Table Names: Plural form of entity names
Code Structure
src/MasLazu.AspNet.Authentication.Core.EfCore/
├── Configurations/ # Entity type configurations
├── Data/ # DbContext classes
├── Extensions/ # DI registration extensions
├── MasLazu.AspNet.Authentication.Core.EfCore.csproj
└── README.md
Best Practices
- Use fluent API for complex mappings
- Define indexes for performance-critical queries
- Configure cascade delete behaviors appropriately
- Use separate read/write contexts for CQRS
- Include data annotations for simple validations
- Follow EF Core migration best practices
🤝 Contributing
- New Entities: Create corresponding configuration classes
- Relationships: Define foreign keys and navigation properties
- Indexes: Add indexes for query performance
- Migrations: Test migrations thoroughly before applying
- Performance: Optimize queries and consider read replicas
- Testing: Add integration tests for data access
📄 License
Part of the MasLazu ASP.NET framework ecosystem.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- MasLazu.AspNet.Authentication.Core.Domain (>= 1.0.0-preview.10)
- MasLazu.AspNet.Framework.EfCore (>= 1.0.0-preview.15)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-preview.10 | 140 | 10/8/2025 |
| 1.0.0-preview.9 | 137 | 10/2/2025 |
| 1.0.0-preview.8 | 135 | 10/1/2025 |
| 1.0.0-preview.7 | 135 | 10/1/2025 |
| 1.0.0-preview.5 | 145 | 9/29/2025 |
| 1.0.0-preview.3 | 263 | 9/18/2025 |
See RELEASES.md for release notes.