![]() |
VOOZH | about |
dotnet add package Enigmatry.Entry.Core.EntityFramework --version 10.2.3
NuGet\Install-Package Enigmatry.Entry.Core.EntityFramework -Version 10.2.3
<PackageReference Include="Enigmatry.Entry.Core.EntityFramework" Version="10.2.3" />
<PackageVersion Include="Enigmatry.Entry.Core.EntityFramework" Version="10.2.3" />Directory.Packages.props
<PackageReference Include="Enigmatry.Entry.Core.EntityFramework" />Project file
paket add Enigmatry.Entry.Core.EntityFramework --version 10.2.3
#r "nuget: Enigmatry.Entry.Core.EntityFramework, 10.2.3"
#:package Enigmatry.Entry.Core.EntityFramework@10.2.3
#addin nuget:?package=Enigmatry.Entry.Core.EntityFramework&version=10.2.3Install as a Cake Addin
#tool nuget:?package=Enigmatry.Entry.Core.EntityFramework&version=10.2.3Install as a Cake Tool
This library provides extension methods and utilities for Entity Framework Core, focusing on querying and data seeding.
Use this library when you need additional query capabilities with Entity Framework Core, such as entity not found handling, mapping query results, and pagination support.
Add the package to your project:
dotnet add package Enigmatry.Entry.Core.EntityFramework
using Enigmatry.Entry.Core.EntityFramework;
using Enigmatry.Entry.Core.Entities;
using Enigmatry.Entry.Core.Paging;
using Microsoft.EntityFrameworkCore;
using System.Threading.Tasks;
// Sample entity class
public class Product
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public decimal Price { get; set; }
public bool IsAvailable { get; set; }
}
public class ProductDto
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public decimal Price { get; set; }
}
public class ProductService
{
private readonly DbContext _dbContext;
private readonly IMapper _mapper;
public ProductService(DbContext dbContext, IMapper mapper)
{
_dbContext = dbContext;
_mapper = mapper;
}
// Find a product by ID, throw exception if not found
public async Task<Product> GetProductById(int id)
{
return await _dbContext.Set<Product>()
.Where(p => p.Id == id)
.SingleOrNotFoundAsync();
}
// Map a single entity to a DTO
public async Task<ProductDto> GetProductDtoById(int id)
{
return await _dbContext.Set<Product>()
.Where(p => p.Id == id)
.SingleOrDefaultMappedAsync<Product, ProductDto>(_mapper);
}
// Map a collection of entities to DTOs
public async Task<List<ProductDto>> GetAvailableProductDtos()
{
return await _dbContext.Set<Product>()
.Where(p => p.IsAvailable)
.ToListMappedAsync<Product, ProductDto>(_mapper);
}
// Get a paged response of products
public async Task<PagedResponse<Product>> GetPagedProducts(int pageNumber, int pageSize)
{
var request = new PagedRequest
{
PageNumber = pageNumber,
PageSize = pageSize,
SortBy = "Name",
SortDirection = "asc"
};
return await _dbContext.Set<Product>()
.Where(p => p.IsAvailable)
.ToPagedResponseAsync(request);
}
}
This library builds on Entity Framework Core and has the following dependencies:
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
// Register DbContext
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
}
}
using Enigmatry.Entry.Core.EntityFramework.Seeding;
using Microsoft.EntityFrameworkCore;
// Create a seeder class
public class ProductSeeder : ISeeding
{
public void Seed(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Product>().HasData(
new Product
{
Id = 1,
Name = "Product 1",
Price = 19.99m,
IsAvailable = true
},
new Product
{
Id = 2,
Name = "Product 2",
Price = 29.99m,
IsAvailable = true
},
new Product
{
Id = 3,
Name = "Product 3",
Price = 39.99m,
IsAvailable = false
}
);
}
}
// Use the seeder in your DbContext
public class ApplicationDbContext : DbContext
{
public DbSet<Product> Products { get; set; } = default!;
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
// Apply the seeder
new ProductSeeder().Seed(modelBuilder);
}
}
| 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 2 NuGet packages that depend on Enigmatry.Entry.Core.EntityFramework:
| Package | Downloads |
|---|---|
|
Enigmatry.Entry.EntityFramework
Building Block for adding EntityFramework related infrastructure to an Entry based project |
|
|
Enigmatry.Entry.SmartEnums.EntityFramework
Building Block for support of SmartEnums with EntityFramework in an Entry based project |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.2.3 | 154 | 6/1/2026 |
| 10.2.3-preview.4 | 62 | 6/1/2026 |
| 10.2.2 | 368 | 4/27/2026 |
| 10.2.1-preview.1 | 64 | 4/27/2026 |
| 10.1.0 | 295 | 4/16/2026 |
| 10.0.1 | 201 | 5/19/2026 |
| 10.0.1-preview.2 | 71 | 4/16/2026 |
| 10.0.0 | 140 | 4/2/2026 |
| 9.6.0 | 552 | 3/18/2026 |
| 9.5.0 | 976 | 1/26/2026 |
| 9.4.0 | 1,838 | 12/22/2025 |
| 9.3.1-preview.3 | 288 | 12/18/2025 |
| 9.3.1-preview.1 | 514 | 11/25/2025 |
| 9.3.0 | 1,224 | 11/10/2025 |
| 9.2.0 | 1,573 | 9/24/2025 |
| 9.1.1-preview.5 | 234 | 8/8/2025 |
| 9.1.1-preview.4 | 154 | 6/27/2025 |
| 8.3.1-preview.1 | 176 | 12/24/2025 |
| 8.3.0 | 1,869 | 12/23/2025 |
| 8.2.0 | 678 | 9/24/2025 |