Shipeng.EntityFrameworkCore 4.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Shipeng.EntityFrameworkCore --version 4.1.0
                    
NuGet\Install-Package Shipeng.EntityFrameworkCore -Version 4.1.0
                    
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="Shipeng.EntityFrameworkCore" Version="4.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Shipeng.EntityFrameworkCore" Version="4.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Shipeng.EntityFrameworkCore" />
                    
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 Shipeng.EntityFrameworkCore --version 4.1.0
                    
#r "nuget: Shipeng.EntityFrameworkCore, 4.1.0"
                    
#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 Shipeng.EntityFrameworkCore@4.1.0
                    
#: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=Shipeng.EntityFrameworkCore&version=4.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Shipeng.EntityFrameworkCore&version=4.1.0
                    
Install as a Cake Tool

Shipeng.EntityFrameworkCore

Shipeng.EntityFrameworkCore 提供 Entity Framework Core 集成能力,包括默认 DbContext、仓储接口、多数据库类型枚举、动态查询辅助、DataReader/ObjectReader 转换和常用扩展。适合以 EF Core 作为主 ORM 的业务系统。

安装

dotnet add package Shipeng.EntityFrameworkCore

适用场景

  • 项目使用 EF Core 访问 SQL Server、SQLite、MySQL、PostgreSQL 或 Oracle。
  • 希望统一仓储接口、DbContext 扩展和动态查询表达式。
  • 需要在基础设施层复用分页、排序、字典、字符串、类型转换等 EF 相关扩展。

主要类型

  • DefaultDbContext:默认 EF Core 上下文基类。
  • IRepository:仓储接口抽象。
  • SqlRepositorySqliteRepositoryMySqlRepositoryNpgsqlRepositoryOracleRepository:不同数据库的仓储实现/扩展入口。
  • DatabaseType:数据库类型枚举。
  • DbContextExtensionsLinqExtensionsFormattableStringExtensions:查询和上下文扩展。
  • IServiceCollectionExtensions:EF Core 服务注册扩展。
  • MatchTypeOrderType:动态查询匹配和排序枚举。
  • ObjectReaderIDataReaderExtensions:对象和 DataReader 转换辅助。

基本用法

using Microsoft.EntityFrameworkCore;
using Shipeng.Foundation.EntityFrameworkCore;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddDbContext<DefaultDbContext>(options =>
{
    options.UseSqlServer(builder.Configuration.GetConnectionString("Default"));
});

var app = builder.Build();
app.Run();

使用建议

  • DbContext 生命周期使用 Scoped,不要注册为 Singleton。
  • 查询列表必须注意投影,只取页面需要的字段。
  • 写操作使用事务时,事务边界应放在应用服务层,不要跨越外部网络调用。
  • 多数据库项目应按实际数据库引用驱动,避免业务项目引入不需要的 provider。

API Reference / API 索引

完整公开类型、方法、属性签名请查看 API_REFERENCE.md。该文件从源码 public 声明生成,用于补充 README 中的场景说明和示例。

Product 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. 
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
4.1.1 99 6/30/2026
4.1.0 100 6/30/2026

4.1.0: Split the original monolithic foundation library into focused Shipeng.* NuGet packages. Consumers can reference authentication, MongoDB, SqlSugar, EF Core, database index, third-party integration, logging, mapping, payment, and hybrid paging capabilities on demand.