EFCoreLayerKit 1.0.5

dotnet add package EFCoreLayerKit --version 1.0.5
                    
NuGet\Install-Package EFCoreLayerKit -Version 1.0.5
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EFCoreLayerKit" Version="1.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EFCoreLayerKit" Version="1.0.5" />
                    
Directory.Packages.props
<PackageReference Include="EFCoreLayerKit" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add EFCoreLayerKit --version 1.0.5
                    
#r "nuget: EFCoreLayerKit, 1.0.5"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package EFCoreLayerKit@1.0.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=EFCoreLayerKit&version=1.0.5
                    
Install as a Cake Addin
#tool nuget:?package=EFCoreLayerKit&version=1.0.5
                    
Install as a Cake Tool

简体中文 | English

NuGet NuGet Downloads License: MIT GitHub stars

EFCoreLayerKit

EFCoreLayerKit is a general-purpose data access layer toolkit based on Entity Framework Core. It supports automatic repository registration, DTO mapping, soft deletion, automatic migration, and more. Suitable for .NET 8+ projects.


Features

  • Automatically register all DbContexts inheriting from BaseDbContext and migrate database schema
  • Automatically register all repositories inheriting from BaseRepository<TEntity>
  • Support for soft delete, optimistic concurrency, batch operations, and other common data access patterns
  • Automatic two-way mapping between DTOs and entities (based on AutoMapper)
  • Rich result types (FResult, FResult<T>, FPagedResult<T>)
  • Designed for DI scenarios such as Blazor and ASP.NET Core

Installation

Make sure your project references the following NuGet packages:

  • Microsoft.EntityFrameworkCore
  • Microsoft.EntityFrameworkCore.Sqlite
  • AutoMapper
  • System.Linq.Dynamic.Core
  • EFCoreLayerKit (this library)

Quick Start

  1. Define Entities and DbContext public class Author : BaseEntity { public string Name { get; set; } public virtual ICollection<Book> Books { get; set; } }

public class Book : BaseEntity { public string Title { get; set; } public long AuthorId { get; set; } public virtual Author Author { get; set; } }

public class TestDbContext : BaseDbContext { public DbSet<Author> Authors { get; set; } public DbSet<Book> Books { get; set; } } 2. Define Repository Classes public class AuthorRepository : BaseRepository<Author> { public AuthorRepository(TestDbContext ctx) : base(ctx) { } }

public class BookRepository : BaseRepository<Book> { public BookRepository(TestDbContext ctx) : base(ctx) { } } 3. Register Services and Auto-Migrate

In Program.cs: var services = new ServiceCollection(); services.AddEFCoreLayerKit(); var provider = services.BuildServiceProvider(); All DbContexts will automatically call EnsureDatabaseMigrated() during registration, so you do not need to manually migrate.

  1. Use Repositories for Data Operations var authorRepo = provider.GetRequiredService<AuthorRepository>(); var bookRepo = provider.GetRequiredService<BookRepository>();

// Add data var author = new Author { Name = "Zhang San" }; var addAuthorResult = await authorRepo.AddAsync(author);

var book = new Book { Title = "C# Beginner", AuthorId = author.Id }; var addBookResult = await bookRepo.AddAsync(book);

// Query authors = await authorRepo.GetAllAsync();

// Update author.Name = "Li Si"; var updateAuthorResult = await authorRepo.UpdateAsync(author);

// Delete var deleteAuthorResult = await authorRepo.DeleteAsync(author.Id);

Result Types

  • FResult: General operation result, including success flag, message, error code, etc.
  • FResult<T>: Operation result with data.
  • FPagedResult<T>: Paged result with data and pagination info.

All result types support formatted messages, error codes, and log conversion.


Advanced Usage

  • Custom repositories, DTO mapping, global query filters
  • Batch operations, soft delete, optimistic concurrency
  • See source code comments and extension methods for more

Testing & Examples

A complete test project (EFCoreLayerKitTest) is included. You can run Program.cs to see CRUD and other features in action.


License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.0.5 11 8/6/2025
1.0.4 12 8/6/2025
1.0.3 12 8/2/2025
1.0.2 86 7/31/2025
1.0.1 85 7/30/2025
1.0.0 88 7/30/2025