开放代码社区 › English 中文
English 中文
AI/机器学习C#English 中文 ShardingCore high performance lightweight solution for efcore sharding table and sharding database support read-write-separation. zero dependency zero learning cost zero incursion Special user 全项目基于.Net专业团队自研,源头工厂,价格约是官方的二十分之一不到,获得全网数万用户好评,稳定安全,快速可靠! ①支持 编程/对话/视频/图片/翻译/知识库/插件 直接使用 等等。
仓库地址
https://gitee.com/xuejm/sharding-core.gitREADME
<p align="center">
<img height="340" src="https://xuejmnet.github.io/sharding-core-doc/logo.svg">
</p>
<p align="center">
<a target="_blank" href='https://gitee.com/xuejm/sharding-core'>
<img src='https://gitee.com/xuejm/sharding-core/badge/star.svg' alt='Gitee star'/>
</a>
<a target="_blank" href='https://github.com/dotnetcore/sharding-core'>
<img src="https://img.shields.io/github/stars/dotnetcore/sharding-core.svg?logo=github" alt="Github star"/>
</a>
<a href='https://gitcode.com/xuejmnet/sharding-core'><img src='https://gitcode.com/xuejmnet/sharding-core/star/badge.svg' alt='fork'></a>
</p>
# English | [中文](https://github.com/dotnetcore/sharding-core/blob/main/README-zh.md)
# ShardingCore
high performance lightweight solution for efcore sharding table and sharding database support read-write-separation.
- zero dependency
- zero learning cost
- zero incursion
---
## Special user
<p>
<a href="https://yxai.chat/" target="_blank">
<img alt="yixin-Logo" src="https://web-code-img.oss-cn-shanghai.aliyuncs.com/readme/3f7b24fc04421173dfdf63c9.png" height="100px">
</a>
</p>
全项目基于.Net专业团队自研,源头工厂,价格约是官方的二十分之一不到,获得全网数万用户好评,稳定安全,快速可靠!
- ①支持 编程/对话/视频/图片/翻译/知识库/插件 直接使用 等等。
- ②支持全球顶流模型,支持最强编程ClaudeCode/Codex/GeminiCli。
- ③支持一个key通用claude、gpt、gemini等全站模型。
- ④包售后,充值后提供1对1售后服务,手把手教玩ai 。
用Ai就选择意心Ai,省心放心爽用!让你不再有Ai焦虑!
- [捐赠](#捐赠)
<img src="https://web-code-img.oss-cn-shanghai.aliyuncs.com/readme/d85dd7f0449d1ab16bcfa551.jpg" title="git-code" width=330 />
<img src="https://web-code-img.oss-cn-shanghai.aliyuncs.com/readme/51dae08cb8ab38a97fcedd96.jpg" title="gitee" width=330 />
## Community Partners and Sponsors
<a href="https://www.jetbrains.com/?from=.NETCoreCommunity(NCC)" target="_blank">
<img src="https://web-code-img.oss-cn-shanghai.aliyuncs.com/readme/f39e19a2e29c658459a16360.png" title="JetBrains" width=130 />
</a>
## 📚 Documentation
[中文文档](https://www.easy-query.com:1443/)
## How Choose Version
- shardingcore lastversion.efcoreversion.x.x
- first version is shardingcore version
- second version is efcore version
- other version use last version
-
- efcore10 use shardingcore7.10.x.x
- efcore9 use shardingcore7.9.x.x
- efcore8 use shardingcore7.8.x.x
- efcore7 use shardingcore7.7.x.x
- efcore6 use shardingcore7.6.x.x
- efcore5 use shardingcore7.5.x.x
- efcore3 use shardingcore7.3.x.x
- efcore2 use shardingcore7.2.x.x
## Abp.VNext、WTM、FURION
- [ShardingFrameWork](https://github.com/xuejmnet/ShardingWithFramework) demos
## Dependency
### Before ShardingCore 6.7.0.0
Release | EF Core | .NET | .NET (Core)
--- | --- | --- | ---
[6.x.x.x](https://www.nuget.org/packages/ShardingCore) | 6.0.0 | net 6.0 | 6.0+
[5.x.x.x](https://www.nuget.org/packages/ShardingCore) | 5.0.10 | Standard 2.1 | 5.0+
[3.x.x.x](https://www.nuget.org/packages/ShardingCore) | 3.1.18 | Standard 2.0 | 2.0+
[2.x.x.x](https://www.nuget.org/packages/ShardingCore) | 2.2.6 | Standard 2.0 | 2.0+
### After ShardingCore 6.7.0.0
Use Condition Compile With NetFramework not
Release | EF Core | .NET (Core)
--- | --- | ---
[6.7.0.0+](https://www.nuget.org/packages/ShardingCore)| 6.x | net6
[6.7.0.0+](https://www.nuget.org/packages/ShardingCore)| 5.x | net5 or netstandard2.1
[6.7.0.0+](https://www.nuget.org/packages/ShardingCore)| 3.x | netcoreapp3 or netstandard2.0
[6.7.0.0+](https://www.nuget.org/packages/ShardingCore)| 2.x | netcoreapp2
## Quick start
5 steps implement sharding by month and support auto create table by month
### Step 1: Install the package
Choose data base driver for efcore
```shell
# basic package[README-zh.md](https://gitee.com/xuejm/sharding-core/blob/main/README-zh.md)
PM> Install-Package ShardingCore
# sqlserver driver
PM> Install-Package Microsoft.EntityFrameworkCore.SqlServer
# mysql driver
#PM> Install-Package Pomelo.EntityFrameworkCore.MySql
# use other database driver,if efcore support
```
### Step 2: Query entity
Query entity order
```csharp
/// <summary>
/// order table
/// </summary>
public class Order
{
/// <summary>
/// order Id
/// </summary>
public string Id { get; set; }
/// <summary>
/// payer id
/// </summary>
public string Payer { get; set; }
/// <summary>
/// pay money cent
/// </summary>
public long Money { get; set; }
/// <summary>
/// area
/// </summary>
public string Area { get; set; }
/// <summary>
/// order status
/// </summary>
public OrderStatusEnum OrderStatus { get; set; }
/// <summary>
/// CreationTime
/// </summary>
public DateTime CreationTime { get; set; }
}
public enum OrderStatusEnum
{
NoPay=1,
Paying=2,
Payed=3,
PayFail=4
}
```
### Step 3: Create DbContext
Create `MyDbContext` extends `AbstractShardingDbContext`,
then this dbcontext support sharding database,if u want support
sharding table(spilt table eg. order_202101,order_202102,order_202103......),u need implements `IShardingTableDbContext`
```csharp
public class MyDbContext:AbstractShardingDbContext,IShardingTableDbContext
{
public MyDbContext(DbContextOptions<MyDbContext> options) : base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Order>(entity =>
{
entity.HasKey(o => o.Id);
entity.Property(o => o.Id).IsRequired().IsUnicode(false).HasMaxLength(50);
entity.Property(o=>o.Payer).IsRequired().IsUnicode(false).HasMaxLength(50);
entity.Property(o => o.Area).IsRequired().IsUnicode(false).HasMaxLength(50);
entity.Property(o => o.OrderStatus).HasConversion<int>();
//reall