Common.EFCore 1.4.0-beta1

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

Common.EFCore

操作例子

只是包含EFCore公共Base类

Statrup的ConfigureServices方法添加

services.AddAutoGenerationId(); //增加自增ID

继承公共基类

IdentityBaseEntity、IdentityBaseEntity<TKey>
IdentityOperatorEntity、IdentityOperatorEntity<Tkey>
IdentityOperatorStatusEntity、  IdentityOperatorStatusEntity<TKey>

模型配置继承

EntityTypeConfigurationIdentity、EntityTypeConfigurationIdentity<T, TKey>
EntityTypeConfigurationIdentityOperator、EntityTypeConfigurationIdentityOperator<T,TKey>
EntityTypeConfigurationIdentityOperatorStatus、EntityTypeConfigurationIdentityOperatorStatus<T, TKey>
多上下文的情况

注入示例

service.AddEntityFramework<TestDbContext>(options =>
       {
           options.ConnectionString = connectionStr;
           options.Schema = "public";
       })
       .AddUnitOfWork<TestDbContext>();

service.AddEntityFramework<TestDb2Context>(options =>
       {
           options.ConnectionString = connection2Str;
           options.Schema = "public";
       })
       .AddUnitOfWork<TestDb2Context>();

当需要获取IBaseRepository<IEntity>去操作数据库的时候,不能直接注入IBaseRepository<IEntity>,而应该是通过注入IUnitOfWork<DbContext>来获取,示例如下

var unitOfWork = scope.ServiceProvider.GetRequiredService<IUnitOfWork<TestDbContext>>();
var testDb1Rep = unitOfWork.GetRepository<TestEntity>();
var content = Guid.NewGuid().ToString();
await testDb1Rep.AddAsync(new TestEntity(content));
var flag = await unitOfWork.SaveChangesAsync();
Assert.True(flag > 0);

版本更新记录

  • 1.4.0-beta1
    • 支持.Net9
  • 1.3.2
    • 修复IUnitOfWork<IEntity>在多上下文中保存失败的问题
  • 1.3.1
    • 移出调用工作单元的时候才添加IUnitOfWork,默认会添加一个IUnitOfWork
  • 1.3.0
    • 适配Common.Db.Core的0.1.0版本
    • 增加分页扩展ToPageListAsync
  • 1.3.0-beta4
    • 修改方法SetDelete为SetDeleted
    • 默认设置创建时间的时候使用无时区时间,防止pgsql出问题
  • 1.3.0-beta3
    • 迁移Common.EfCore的类到DBCore中
  • 1.3.0-beta2
    • 升级.Net8
  • 1.3.0-beta1
    • 模型类优化
    • 将pgsql中列的PropertyBuilderExtensions迁移到该程序集
    • 增加BaseRepository作为公共的操作,且方法为虚方法
    • 移除IBaseRepository中的同步方法
  • 1.2.1
    • 查询请求类优化

    • QueryableExtensions类更新

  • 1.2.0
    • GetPageRequest增加一个查询关键字
    • 将EFCoreExtension内容迁移到工作单元下
    • 工作单元类需要单独注入,如services.AddUnitOfWork<BaseDbContext>();
  • 1.2.0-beta2
    • 将创建时间修改时间等改为传入方案,用来应对pgsql的时间区分有时区无时区方案
  • 1.2.0-beta1
    • 升级支持.net7
  • 1.0.0-beta8
    • 增加表达式树扩展方法,替换nuget包System.Linq.Dynamic.Core
  • 1.0.0-beta7
    • 增加执行SQL扩展
    • 增加非追踪
  • 1.0.0-beta5
    • 更新注册的方法从AddEntityBase变更为AddIdHelper()
  • 1.0.0-beta4
    • 支持主键自定义类型
  • 1.1.0-beta3
    • 增加分页相关的类
    • 去除common包的依赖
  • 1.1.0-beta2
    • 更新因为Common包升级导致的问题
  • 1.1.0-beta1
    • 修改版本支持.net5、.net6、.netstandard2.1
    • 修改OrderBy排序方法
  • 1.0.6
    • 修改QueryableExtensions扩展,分页支持返回总条数,如果参数错误抛出异常
  • 1.0.5
    • 修改QueryableExtensions扩展
  • 1.0.4
    • 增加默认注入,支持单独使用该库的model类AddEntityBase
    • 主键ID修改类型为long类型
  • 1.0.3
    • 基本的base类封装
    • IBaseRepository接口编写
    • 工作单元封装
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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 is compatible.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on Common.EFCore:

Package Downloads
Common.EFCore.PostgresSql

操作PostgresSql基础方法

Common.EFCore.InMemory

封装基本的EFCore操作内存数据库的方法

Common.EFCore.MySQL

封住简单操作MySQL的方法

Common.EFCore.SQLite

封装了一些SQLite相关的方法

Common.EFCore.SQLServer

基本的对sqlserver增删改查的封装

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.6.2 97 2/26/2026
1.6.1 100 2/11/2026
1.6.0 181 2/9/2026
1.5.0 244 11/15/2025
1.4.3 323 9/1/2025
1.4.2 546 8/26/2025
1.4.1 283 8/17/2025
1.4.0 369 8/13/2025
1.4.0-beta8 268 8/12/2025
1.4.0-beta7 192 8/9/2025
1.4.0-beta6 183 8/9/2025
1.4.0-beta5 192 7/29/2025
1.4.0-beta4 670 7/23/2025
1.4.0-beta3 304 5/6/2025
1.4.0-beta1 429 3/1/2025
1.3.2 290 8/12/2024
1.3.1 497 8/11/2024
1.3.0 220 7/27/2024
1.3.0-beta4 170 7/27/2024
1.3.0-beta3 295 3/23/2024
Loading failed