![]() |
VOOZH | about |
dotnet add package DKNet.EfCore.Extensions --version 10.0.27
NuGet\Install-Package DKNet.EfCore.Extensions -Version 10.0.27
<PackageReference Include="DKNet.EfCore.Extensions" Version="10.0.27" />
<PackageVersion Include="DKNet.EfCore.Extensions" Version="10.0.27" />Directory.Packages.props
<PackageReference Include="DKNet.EfCore.Extensions" />Project file
paket add DKNet.EfCore.Extensions --version 10.0.27
#r "nuget: DKNet.EfCore.Extensions, 10.0.27"
#:package DKNet.EfCore.Extensions@10.0.27
#addin nuget:?package=DKNet.EfCore.Extensions&version=10.0.27Install as a Cake Addin
#tool nuget:?package=DKNet.EfCore.Extensions&version=10.0.27Install as a Cake Tool
👁 NuGet
👁 NuGet Downloads
👁 .NET
Enhanced Entity Framework Core functionality with automatic entity configuration, global query filters, data seeding, and advanced extension methods. This package streamlines EF Core setup and provides powerful utilities for entity management, pagination, and database operations.
Install via NuGet Package Manager:
dotnet add package DKNet.EfCore.Extensions
Or via Package Manager Console:
Install-Package DKNet.EfCore.Extensions
using Microsoft.EntityFrameworkCore;
using DKNet.EfCore.Extensions;
public class AppDbContext : DbContext
{
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
// Automatically configure all entities from assemblies
modelBuilder.UseAutoConfigModel<AppDbContext>(config =>
{
config.AddAssembly(typeof(Product).Assembly);
config.AddAssembly(typeof(Customer).Assembly);
});
base.OnModelCreating(modelBuilder);
}
}
// Configure in Startup/Program
services.AddDbContext<AppDbContext>(options =>
options.UseSqlServer(connectionString)
.UseAutoConfigModel<AppDbContext>());
using DKNet.EfCore.Extensions.Configurations;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
public class ProductConfiguration : DefaultEntityTypeConfiguration<Product>
{
public override void Configure(EntityTypeBuilder<Product> builder)
{
// Apply default configurations (Id, audit properties, etc.)
base.Configure(builder);
// Add custom configurations
builder.Property(p => p.Name)
.HasMaxLength(255)
.IsRequired();
builder.Property(p => p.Price)
.HasPrecision(18, 2);
builder.HasIndex(p => p.Sku)
.IsUnique();
}
}
using DKNet.EfCore.Extensions.Configurations;
public class SoftDeleteQueryFilter : IGlobalQueryFilterRegister
{
public void RegisterFilters(ModelBuilder modelBuilder)
{
// Apply soft delete filter globally
foreach (var entityType in modelBuilder.Model.GetEntityTypes())
{
if (typeof(ISoftDeletableEntity).IsAssignableFrom(entityType.ClrType))
{
var parameter = Expression.Parameter(entityType.ClrType, "e");
var property = Expression.Property(parameter, nameof(ISoftDeletableEntity.IsDeleted));
var condition = Expression.Equal(property, Expression.Constant(false));
var lambda = Expression.Lambda(condition, parameter);
modelBuilder.Entity(entityType.ClrType).HasQueryFilter(lambda);
}
}
}
}
// Register in Startup
services.AddGlobalModelBuilderRegister<SoftDeleteQueryFilter>();
using DKNet.EfCore.Extensions.Configurations;
public class CategorySeedData : IDataSeedingConfiguration<Category>
{
public async Task SeedAsync(DbContext context, IServiceProvider serviceProvider)
{
var repository = serviceProvider.GetRequiredService<ICategoryRepository>();
if (!await repository.AnyAsync())
{
var categories = new[]
{
new Category("Electronics", "Electronic devices"),
new Category("Books", "Books and publications"),
new Category("Clothing", "Apparel and accessories")
};
await repository.AddRangeAsync(categories);
await context.SaveChangesAsync();
}
}
}
// Apply seeding
await context.SeedDataAsync<Category>();
services.AddDbContext<AppDbContext>(options =>
{
options.UseSqlServer(connectionString)
.UseAutoConfigModel<AppDbContext>(config =>
{
// Add specific assemblies
config.AddAssembly(typeof(Product).Assembly);
// Exclude specific entity types
config.ExcludeEntity<TemporaryEntity>();
// Configure naming conventions
config.UseSnakeCaseNaming();
config.UsePluralTableNames();
});
});
UseAutoConfigModel<TContext>() - Auto-configure entities from assembliesAddGlobalModelBuilderRegister<T>() - Register global query filtersSeedDataAsync<TEntity>() - Perform structured data seedingGetTableName(Type) - Get schema-qualified table name for entityGetPrimaryKeyProperty(Type) - Extract primary key property informationGetPrimaryKeyValue(object) - Get primary key value from entity instanceGetNextSequenceValue(string) - Get next value from database sequenceGetFormattedSequenceValue(string, string) - Get formatted sequence with prefix/suffixCreateSnapshot() - Create entity state snapshot for change trackingGetChanges(SnapshotContext) - Detect changes between snapshotspublic class InvoiceConfiguration : DefaultEntityTypeConfiguration<Invoice>
{
public override void Configure(EntityTypeBuilder<Invoice> builder)
{
base.Configure(builder);
// Configure SQL sequence for invoice numbers
builder.Property(i => i.InvoiceNumber)
.HasDefaultValueSql("NEXT VALUE FOR invoice_number_seq");
// Configure custom table and schema
builder.ToTable("Invoices", "billing");
// Configure relationships
builder.HasMany(i => i.LineItems)
.WithOne(li => li.Invoice)
.HasForeignKey(li => li.InvoiceId)
.OnDelete(DeleteBehavior.Cascade);
}
}
public class TenantQueryFilter : IGlobalQueryFilterRegister
{
private readonly IHttpContextAccessor _httpContextAccessor;
public TenantQueryFilter(IHttpContextAccessor httpContextAccessor)
{
_httpContextAccessor = httpContextAccessor;
}
public void RegisterFilters(ModelBuilder modelBuilder)
{
var tenantId = GetCurrentTenantId();
foreach (var entityType in modelBuilder.Model.GetEntityTypes())
{
if (typeof(ITenantEntity).IsAssignableFrom(entityType.ClrType))
{
var parameter = Expression.Parameter(entityType.ClrType, "e");
var property = Expression.Property(parameter, nameof(ITenantEntity.TenantId));
var condition = Expression.Equal(property, Expression.Constant(tenantId));
var lambda = Expression.Lambda(condition, parameter);
modelBuilder.Entity(entityType.ClrType).HasQueryFilter(lambda);
}
}
}
private Guid GetCurrentTenantId()
{
// Extract tenant ID from HTTP context, claims, etc.
return _httpContextAccessor.HttpContext?.User
?.FindFirst("tenant_id")?.Value
?? Guid.Empty;
}
}
public class ProductSeedData : IDataSeedingConfiguration<Product>
{
public async Task SeedAsync(DbContext context, IServiceProvider serviceProvider)
{
var categoryRepo = serviceProvider.GetRequiredService<ICategoryRepository>();
var logger = serviceProvider.GetRequiredService<ILogger<ProductSeedData>>();
try
{
if (!await context.Set<Product>().AnyAsync())
{
var categories = await categoryRepo.GetAllAsync();
var electronics = categories.First(c => c.Name == "Electronics");
var products = new[]
{
new Product("Laptop", 1299.99m, electronics.Id, "admin"),
new Product("Mouse", 29.99m, electronics.Id, "admin"),
new Product("Keyboard", 89.99m, electronics.Id, "admin")
};
context.Set<Product>().AddRange(products);
await context.SaveChangesAsync();
logger.LogInformation("Seeded {Count} products", products.Length);
}
}
catch (Exception ex)
{
logger.LogError(ex, "Failed to seed product data");
throw;
}
}
}
The auto-configuration system follows these rules:
IEntity<TKey> from specified assemblies[IgnoreEntity] attributeSee the main for guidelines on how to contribute to this project.
This project is licensed under the .
Part of the DKNet Framework - A comprehensive .NET framework for building modern, scalable applications.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 4 NuGet packages that depend on DKNet.EfCore.Extensions:
| Package | Downloads |
|---|---|
|
DKNet.EfCore.Hooks
DKNet is an enterprise-grade .NET library collection focused on advanced EF Core extensions, dynamic predicate building, and the Specification pattern. It provides production-ready tools for building robust, type-safe, and testable data access layers, including dynamic LINQ support, LinqKit integration. Designed for modern cloud-native applications, DKNet enforces strict code quality, async best practices, and full documentation for all public APIs. Enterprise-grade .NET library suite for modern application development, featuring advanced EF Core extensions (dynamic predicates, specifications, LinqKit), robust Domain-Driven Design (DDD) patterns, and domain event support. DKNet empowers scalable, maintainable, and testable solutions with type-safe validation, async/await, XML documentation, and high code quality standards. Ideal for cloud-native, microservices, and enterprise architectures. |
|
|
DKNet.EfCore.DataAuthorization
DKNet is an enterprise-grade .NET library collection focused on advanced EF Core extensions, dynamic predicate building, and the Specification pattern. It provides production-ready tools for building robust, type-safe, and testable data access layers, including dynamic LINQ support, LinqKit integration. Designed for modern cloud-native applications, DKNet enforces strict code quality, async best practices, and full documentation for all public APIs. Enterprise-grade .NET library suite for modern application development, featuring advanced EF Core extensions (dynamic predicates, specifications, LinqKit), robust Domain-Driven Design (DDD) patterns, and domain event support. DKNet empowers scalable, maintainable, and testable solutions with type-safe validation, async/await, XML documentation, and high code quality standards. Ideal for cloud-native, microservices, and enterprise architectures. |
|
|
DKNet.EfCore.Repos
Package Description |
|
|
DKNet.EfCore.Specifications
DKNet is an enterprise-grade .NET library collection focused on advanced EF Core extensions, dynamic predicate building, and the Specification pattern. It provides production-ready tools for building robust, type-safe, and testable data access layers, including dynamic LINQ support, LinqKit integration. Designed for modern cloud-native applications, DKNet enforces strict code quality, async best practices, and full documentation for all public APIs. Enterprise-grade .NET library suite for modern application development, featuring advanced EF Core extensions (dynamic predicates, specifications, LinqKit), robust Domain-Driven Design (DDD) patterns, and domain event support. DKNet empowers scalable, maintainable, and testable solutions with type-safe validation, async/await, XML documentation, and high code quality standards. Ideal for cloud-native, microservices, and enterprise architectures. |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.0.27 | 201 | 5/22/2026 |
| 10.0.26 | 158 | 5/19/2026 |
| 10.0.25 | 448 | 3/27/2026 |
| 10.0.24 | 164 | 3/27/2026 |
| 10.0.23 | 164 | 3/27/2026 |
| 10.0.22 | 152 | 3/26/2026 |
| 10.0.21 | 207 | 3/17/2026 |
| 10.0.20 | 165 | 2/2/2026 |
| 10.0.19 | 323 | 1/21/2026 |
| 10.0.18 | 165 | 1/21/2026 |
| 10.0.17 | 185 | 1/19/2026 |
| 10.0.16 | 165 | 1/18/2026 |
| 10.0.15 | 172 | 1/18/2026 |
| 10.0.14 | 164 | 1/18/2026 |
| 10.0.13 | 165 | 1/17/2026 |
| 10.0.12 | 171 | 1/17/2026 |
| 10.0.11 | 174 | 1/17/2026 |
| 10.0.10 | 163 | 1/17/2026 |
| 10.0.9 | 174 | 1/16/2026 |
| 10.0.8 | 170 | 1/16/2026 |