Hasim.EntityFrameworkCore
0.1.1
dotnet add package Hasim.EntityFrameworkCore --version 0.1.1
NuGet\Install-Package Hasim.EntityFrameworkCore -Version 0.1.1
<PackageReference Include="Hasim.EntityFrameworkCore" Version="0.1.1" />
<PackageVersion Include="Hasim.EntityFrameworkCore" Version="0.1.1" />
<PackageReference Include="Hasim.EntityFrameworkCore" />
paket add Hasim.EntityFrameworkCore --version 0.1.1
#r "nuget: Hasim.EntityFrameworkCore, 0.1.1"
#:package Hasim.EntityFrameworkCore@0.1.1
#addin nuget:?package=Hasim.EntityFrameworkCore&version=0.1.1
#tool nuget:?package=Hasim.EntityFrameworkCore&version=0.1.1
Hasim.EntityFrameworkCore
A customizable ASP.NET Core Identity entities library providing reusable base identity models and common abstractions for modern .NET applications.
Built on top of Entity Framework Core, this library ships an audit-enabled DbContext (derived from IdentityDbContext), ready-to-use entity type configurations, and a dependency-injection module so you can wire up SQL Server + Identity + audit logging in a few lines.
✨ Features
- Identity-ready
DbContext—AuditIdentityContextextendsIdentityDbContextwithint-keyed identity types (AppUser,AppRole, claims, roles, logins, tokens). - Audit logging out of the box — built-in
AuditLogandEntityChangeentities to track who did what, when. - EF Core configurations — table mappings, indexes, and relationships are defined via
IEntityTypeConfiguration<T>implementations and applied automatically. - Pluggable DI module — an Injectify-based
EntityFrameworkCoreModuleregisters the context with the SQL Server provider and the audit interceptor. - Packaged as a NuGet library — drop it into any ASP.NET Core app.
📦 Installation
dotnet add package Hasim.EntityFrameworkCore
🚀 Getting Started
1. Configure the connection string
Add a DefaultConnection connection string to your appsettings.json:
{
"ConnectionStrings": {
"DefaultConnection": "Server=localhost;Database=YourDb;Trusted_Connection=True;TrustServerCertificate=True;MultipleActiveResultSets=true"
}
}
2. Register the module
Register the EntityFrameworkCoreModule through your DI container (Injectify). The module:
- Adds
AuditIdentityContextto the service collection. - Configures it to use the SQL Server provider and the
DefaultConnectionconnection string. - Attaches the
PersistingAuditInterceptor(fromHasim.Auditify) to persist audit entries automatically.
3. Use the context
Resolve AuditIdentityContext (or inject it into your services) and work with the exposed DbSets:
using Hasim.EntityFrameworkCore.Persistence;
using Microsoft.EntityFrameworkCore;
// Inside your service
public class MyService(AuditIdentityContext db)
{
public async Task DoSomethingAsync(CancellationToken ct = default)
{
// e.g. query audit logs
var logs = await db.AuditLogs
.Include(a => a.EntityChanges)
.ToListAsync(ct);
}
}
🧱 Architecture
Hasim.EntityFrameworkCore/
├── Configurations/
│ ├── AuditLogConfiguration.cs # AuditLog table mapping, indexes, relationships
│ ├── EntityChangeConfiguration.cs # EntityChange table mapping
│ └── UserConfiguration.cs # AppUser table mapping
├── Module/
│ └── EntityFrameworkCoreModule.cs # Injectify DI module (SQL Server + audit interceptor)
└── Persistence/
└── AuditIdentityContext.cs # IdentityDbContext + AuditLogs / EntityChanges DbSets
Entities
| Entity | Description |
|---|---|
AuditLog |
High-level audit record (action, entity name, IP address, correlation id, user, timestamp). |
EntityChange |
Detailed property-level change tied to an AuditLog. |
AppUser / AppRole |
Identity user and role models (from Hasim.Core). |
| Claims / logins / tokens | Standard Identity types (AppUserClaim, AppUserRole, AppUserLogin, AppRoleClaim, AppUserToken). |
Database mappings
- Tables:
AuditLog,EntityChange,User. AuditLoghas indexes onTimestampandUserId, aRestrictdelete relationship to the user, and aCascadedelete relationship to itsEntityChanges.- Configurations are applied automatically via
ApplyConfigurationsFromAssembly.
📚 Dependencies
- Hasim.Auditify — audit interceptor
- Hasim.Core — base entities
- Hasim.Injectify — DI module system
- Microsoft.AspNetCore.Identity.EntityFrameworkCore 8.x
- Microsoft.EntityFrameworkCore.SqlServer 8.x
- Microsoft.EntityFrameworkCore.Relational 8.x
🔧 Requirements
- .NET 8.0 SDK
🤝 Contributing
- Fork the repository.
- Create a feature branch.
- Submit a pull request.
📄 License
This project is licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. 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. |
-
net8.0
- Hasim.Auditify (>= 0.1.4)
- Hasim.Core (>= 0.1.0)
- Hasim.Injectify (>= 0.1.2)
- Microsoft.AspNetCore.Identity.EntityFrameworkCore (>= 8.0.24)
- Microsoft.EntityFrameworkCore.Relational (>= 8.0.24)
- Microsoft.EntityFrameworkCore.SqlServer (>= 8.0.24)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Hasim.EntityFrameworkCore:
| Package | Downloads |
|---|---|
|
Hasim.Infrastructure
Todo Description. |
GitHub repositories
This package is not used by any popular GitHub repositories.