Hasim.EntityFrameworkCore 0.1.1

dotnet add package Hasim.EntityFrameworkCore --version 0.1.1
                    
NuGet\Install-Package Hasim.EntityFrameworkCore -Version 0.1.1
                    
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="Hasim.EntityFrameworkCore" Version="0.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Hasim.EntityFrameworkCore" Version="0.1.1" />
                    
Directory.Packages.props
<PackageReference Include="Hasim.EntityFrameworkCore" />
                    
Project file
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 Hasim.EntityFrameworkCore --version 0.1.1
                    
#r "nuget: Hasim.EntityFrameworkCore, 0.1.1"
                    
#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 Hasim.EntityFrameworkCore@0.1.1
                    
#: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=Hasim.EntityFrameworkCore&version=0.1.1
                    
Install as a Cake Addin
#tool nuget:?package=Hasim.EntityFrameworkCore&version=0.1.1
                    
Install as a Cake Tool

Hasim.EntityFrameworkCore

.NET NuGet NuGet Downloads Build License: MIT

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 DbContextAuditIdentityContext extends IdentityDbContext with int-keyed identity types (AppUser, AppRole, claims, roles, logins, tokens).
  • Audit logging out of the box — built-in AuditLog and EntityChange entities 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 EntityFrameworkCoreModule registers 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 AuditIdentityContext to the service collection.
  • Configures it to use the SQL Server provider and the DefaultConnection connection string.
  • Attaches the PersistingAuditInterceptor (from Hasim.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.
  • AuditLog has indexes on Timestamp and UserId, a Restrict delete relationship to the user, and a Cascade delete relationship to its EntityChanges.
  • 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

  1. Fork the repository.
  2. Create a feature branch.
  3. Submit a pull request.

📄 License

This project is licensed under the MIT License.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last Updated
0.1.1 256 8/1/2026
0.1.0 106 8/1/2026