NPv.Common.Infrastructure.Db.Ef
1.5.0
dotnet add package NPv.Common.Infrastructure.Db.Ef --version 1.5.0
NuGet\Install-Package NPv.Common.Infrastructure.Db.Ef -Version 1.5.0
<PackageReference Include="NPv.Common.Infrastructure.Db.Ef" Version="1.5.0" />
<PackageVersion Include="NPv.Common.Infrastructure.Db.Ef" Version="1.5.0" />
<PackageReference Include="NPv.Common.Infrastructure.Db.Ef" />
paket add NPv.Common.Infrastructure.Db.Ef --version 1.5.0
#r "nuget: NPv.Common.Infrastructure.Db.Ef, 1.5.0"
#:package NPv.Common.Infrastructure.Db.Ef@1.5.0
#addin nuget:?package=NPv.Common.Infrastructure.Db.Ef&version=1.5.0
#tool nuget:?package=NPv.Common.Infrastructure.Db.Ef&version=1.5.0
Simple Generic Repository Library
📦 Version 1.5.0 — Modernized Unit of Work Support
Brief Description
A foundational infrastructure library designed to streamline Entity Framework Core data access by providing a generic repository pattern and a pluggable unit of work abstraction. It promotes consistency, reusability, and isolation of transactional logic across services, APIs, and background workers.
🚀 Getting Started Started
To integrate this library into your project:
- Add a reference to the package.
- Register your
DbContext
andIDbContextProvider
in the service container. - Use the provided interfaces and base types to simplify CRUD and transaction management.
✅ Quick Example
Create a custom ApplicationContext:
The following demonstrates how to create ApplicationContext:
public class ApplicationContext(DbContextOptions<ApplicationContext> options) : DbContext(options)
{
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
foreach (var entityType in builder.Model.GetEntityTypes()
.Where(t => t.ClrType.IsSubclassOf(typeof(Entity))))
{
var entity = builder.Entity(entityType.ClrType);
entity.Property("Id")
.ValueGeneratedOnAdd()
.HasValueGenerator<GuidV7ValueGenerator>();
}
UserMapping.ApplyMapping(builder);
//other mappings
DefaultString256MaxLengthMapping.ApplyMapping(builder);
}
}
🛠 Usage
When adding a new entity to the database, the Id will be automatically generated.
📜 Changelog
2025-04-19 1.5.0
Improved PerRequestUnitOfWorkProvider with:
- Rename to
DbContextProvider
:IDbContextProvider
-
- Explicit CommitAsync() support
- IsCommitted flag
- ObjectDisposedException.ThrowIf(...) for .NET 9+
- Internal protection against usage after commit/dispose
- Improved compatibility with nested IServiceScope usage (manual vs automatic commit support)
2025-02-15 1.4.1-2
- remove obsolete code
- bugfixing
- refactoring
2025-02-15 1.3.
- broken version
2025-01-14 - Version 1.2.3
- include Version 1.2.2
- Add EFCoreGenericRepository, IUnitOfWorkProvider, PerRequestUnitOfWorkProvider
- Marked as [Obsolete]: PerRequestDbContextProvider, IDbContextProvider, ConsoleDbContextProvider, EfGenericRepository
2024-12-12 - Version 1.2.1
Add GuidV7ValueGenerator
2024-11-18 - Version 1.2.0
- Update to .Net 9
- Update dependencies
- Correct adding README.md
2024-11-12 - Version 1.1.0
- Add README file
- Update to .Net 8
🔐 License
This project is licensed under the MIT License. See the LICENSE.txt file for more information.
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. |
-
net9.0
- Autofac (>= 8.2.0)
- Microsoft.EntityFrameworkCore (>= 9.0.2)
- NPv.Common.Infrastructure.Db (>= 1.2.3)
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 |
---|