EonaCat.EFCore
0.0.1
Prefix Reserved
dotnet add package EonaCat.EFCore --version 0.0.1
NuGet\Install-Package EonaCat.EFCore -Version 0.0.1
<PackageReference Include="EonaCat.EFCore" Version="0.0.1" />
<PackageVersion Include="EonaCat.EFCore" Version="0.0.1" />
<PackageReference Include="EonaCat.EFCore" />
paket add EonaCat.EFCore --version 0.0.1
#r "nuget: EonaCat.EFCore, 0.0.1"
#:package EonaCat.EFCore@0.0.1
#addin nuget:?package=EonaCat.EFCore&version=0.0.1
#tool nuget:?package=EonaCat.EFCore&version=0.0.1
EonaCat.EFCore
A lightweight Entity Framework Core repository and Unit of Work implementation for .NET applications.
EonaCat.EFCore provides:
- Generic Repository pattern
- Command and Query repository separation
- Unit of Work support
- Automatic EF Core migrations
- In-memory database support for testing
- Entity base classes
- Helpful EF Core extension methods
Installation
dotnet add package EonaCat.EFCore
Requirements
- .NET 10.0+
- Entity Framework Core 10+
Quick Start
Create a DbContext
using Microsoft.EntityFrameworkCore;
public class AppDbContext : DbContext
{
public DbSet<User> Users => Set<User>();
public AppDbContext(DbContextOptions<AppDbContext> options)
: base(options)
{
}
}
Create an Entity
using EonaCat.Entities;
public class User : Entity<long>
{
public string Name { get; set; } = string.Empty;
}
Or use the non-generic base class:
public class User : Entity
{
public string Name { get; set; } = string.Empty;
}
Dependency Injection
SQL Server / Relational Database
builder.Services.AddContext<AppDbContext>(options =>
{
options.UseSqlServer(connectionString);
});
This will:
- Register the DbContext
- Apply pending migrations automatically
- Register
IUnitOfWork
In-Memory Database
Useful for testing and development:
builder.Services.AddContextMemory<AppDbContext>();
This will:
- Create an EF Core InMemory database
- Ensure the database is created
- Register
IUnitOfWork
Using the Repository
Create a Repository
public class UserRepository(AppDbContext context)
: EFRepository<User>(context)
{
}
Query Data
var user = repository.Get(1);
var exists = repository.Any(u => u.Name == "John");
var count = repository.Count();
var users = repository.List();
Async Queries
var user = await repository.GetAsync(1);
var exists = await repository.AnyAsync(u => u.Name == "John");
var count = await repository.CountAsync();
var users = await repository.ListAsync();
Insert Data
repository.Add(user);
await unitOfWork.SaveChangesAsync();
Or:
await repository.AddAsync(user);
await unitOfWork.SaveChangesAsync();
Update Data
Full Update
repository.Update(user);
await unitOfWork.SaveChangesAsync();
Partial Update
Update only selected properties:
repository.UpdatePartial(new
{
Id = 1,
Name = "Updated Name"
});
await unitOfWork.SaveChangesAsync();
Delete Data
By primary key:
repository.Delete(1);
await unitOfWork.SaveChangesAsync();
By predicate:
repository.Delete(x => x.IsDeleted);
await unitOfWork.SaveChangesAsync();
Bulk Operations
Add Range
repository.AddRange(users);
await unitOfWork.SaveChangesAsync();
Update Range
repository.UpdateRange(users);
await unitOfWork.SaveChangesAsync();
Delete Range
repository.Delete(users);
await unitOfWork.SaveChangesAsync();
Unit Of Work
public class UserService(
UserRepository repository,
IUnitOfWork unitOfWork)
{
public async Task CreateUser(User user)
{
repository.Add(user);
await unitOfWork.SaveChangesAsync();
}
}
Repository Interfaces
ICommandRepository<T>
Provides write operations:
- Add
- AddRange
- Update
- UpdatePartial
- UpdateRange
- Delete
IQueryRepository<T>
Provides read operations:
- Get
- List
- Any
- Count
IRepository<T>
Combines both command and query functionality.
Entity Base Classes
Generic Entity
public class Product : Entity<Guid>
{
}
Long Id Entity
public class Product : Entity
{
}
Features:
- Equality comparison by Id
- Consistent hash code implementation
- Value-based entity equality
EF Core Extensions
CommandSet
Returns a tracked DbSet<T> configured for write operations.
var set = context.CommandSet<User>();
QuerySet
Returns a no-tracking DbSet<T> optimized for reads.
var set = context.QuerySet<User>();
DetectChangesLazyLoading
Configure EF Core tracking behavior.
context.DetectChangesLazyLoading(true);
PrimaryKeyValues
Retrieve primary key values dynamically.
var keys = context.PrimaryKeyValues<User>(entity);
Why Use EonaCat.EFCore?
- Minimal boilerplate
- Clean repository abstraction
- Async-first API
- EF Core optimized querying
- Built-in Unit of Work
- Supports testing with InMemory databases
- Automatic migration support
- Lightweight and easy to integrate
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- Microsoft.EntityFrameworkCore (>= 10.0.9)
- Microsoft.EntityFrameworkCore.InMemory (>= 10.0.9)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.9)
- Microsoft.Extensions.DependencyInjection (>= 10.0.9)
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 |
|---|---|---|
| 0.0.1 | 137 | 6/9/2026 |