NPv.Common.Infrastructure.Db.Ef
1.6.0
dotnet add package NPv.Common.Infrastructure.Db.Ef --version 1.6.0
NuGet\Install-Package NPv.Common.Infrastructure.Db.Ef -Version 1.6.0
<PackageReference Include="NPv.Common.Infrastructure.Db.Ef" Version="1.6.0" />
<PackageVersion Include="NPv.Common.Infrastructure.Db.Ef" Version="1.6.0" />
<PackageReference Include="NPv.Common.Infrastructure.Db.Ef" />
paket add NPv.Common.Infrastructure.Db.Ef --version 1.6.0
#r "nuget: NPv.Common.Infrastructure.Db.Ef, 1.6.0"
#:package NPv.Common.Infrastructure.Db.Ef@1.6.0
#addin nuget:?package=NPv.Common.Infrastructure.Db.Ef&version=1.6.0
#tool nuget:?package=NPv.Common.Infrastructure.Db.Ef&version=1.6.0
Simple Generic Repository Library
📦 Version 1.6.0 — Entity Enhancements & LongText 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 via GuidV7ValueGenerator
.
Default string column length is limited to 256 characters unless marked with [LongText]
or [MaxLength]
.
📜 Changelog
2025-05-15 1.6
- Added support for
[LongText]
attribute to explicitly marknvarchar(max)
fields - Updated
DefaultString256MaxLengthMapping
to ignore[LongText]
properties - Improved string mapping conventions for EF Core
Internal refactoring and prep for model consistency analysis
2025-04-19 1.5.0
Improved PerRequestUnitOfWorkProvider with:
- Rename to
DbContextProvider
:IDbContextProvider
-
- Explicit
CommitAsync()
support
- Explicit
IsCommitted
flagObjectDisposedException.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.
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)
- NPv.Common.Infrastructure.Domain (>= 1.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.