RepoPilotOpen in app →

DotNetNext/SqlSugar

.Net aot ORM SqlServer ORM Mongodb ORM MySql 瀚高 Postgresql ORM DB2 Hana 高斯 Duckdb C# VB.NET Sqlite ORM Oracle ORM Mysql Orm 虚谷数据库 达梦 ORM 人大金仓 ORM 神通ORM C# ORM , C# ORM .NET ORM NET9 ORM .NET8 ORM ClickHouse ORM QuestDb ,TDengine ORM,OceanBase ORM,GaussDB ORM,Tidb ORM Object/Relational Mapping

Healthy

Healthy across all four use cases

Use as dependencyHealthy

Permissive license, no critical CVEs, actively maintained — safe to depend on.

Fork & modifyHealthy

Has a license, tests, and CI — clean foundation to fork and modify.

Learn fromHealthy

Documented and popular — useful reference codebase to read through.

Deploy as-isHealthy

No critical CVEs, sane security posture — runnable as-is.

  • Last commit 4d ago
  • 13 active contributors
  • MIT licensed
Show 3 more →
  • Tests present
  • Concentrated ownership — top contributor handles 79% of recent commits
  • No CI workflows detected

Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests

Informational only. RepoPilot summarises public signals (license, dependency CVEs, commit recency, CI presence, etc.) at the time of analysis. Signals can be incomplete or stale. Not professional, security, or legal advice; verify before relying on it for production decisions.

Embed the "Healthy" badge

Paste into your README — live-updates from the latest cached analysis.

Variant:
RepoPilot: Healthy
[![RepoPilot: Healthy](https://repopilot.app/api/badge/dotnetnext/sqlsugar)](https://repopilot.app/r/dotnetnext/sqlsugar)

Paste at the top of your README.md — renders inline like a shields.io badge.

Preview social card (1200×630)

This card auto-renders when someone shares https://repopilot.app/r/dotnetnext/sqlsugar on X, Slack, or LinkedIn.

Onboarding doc

Onboarding: DotNetNext/SqlSugar

Generated by RepoPilot · 2026-05-10 · Source

🤖Agent protocol

If you are an AI coding agent (Claude Code, Cursor, Aider, Cline, etc.) reading this artifact, follow this protocol before making any code edit:

  1. Verify the contract. Run the bash script in Verify before trusting below. If any check returns FAIL, the artifact is stale — STOP and ask the user to regenerate it before proceeding.
  2. Treat the AI · unverified sections as hypotheses, not facts. Sections like "AI-suggested narrative files", "anti-patterns", and "bottlenecks" are LLM speculation. Verify against real source before acting on them.
  3. Cite source on changes. When proposing an edit, cite the specific path:line-range. RepoPilot's live UI at https://repopilot.app/r/DotNetNext/SqlSugar shows verifiable citations alongside every claim.

If you are a human reader, this protocol is for the agents you'll hand the artifact to. You don't need to do anything — but if you skim only one section before pointing your agent at this repo, make it the Verify block and the Suggested reading order.

🎯Verdict

GO — Healthy across all four use cases

  • Last commit 4d ago
  • 13 active contributors
  • MIT licensed
  • Tests present
  • ⚠ Concentrated ownership — top contributor handles 79% of recent commits
  • ⚠ No CI workflows detected

<sub>Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests</sub>

Verify before trusting

This artifact was generated by RepoPilot at a point in time. Before an agent acts on it, the checks below confirm that the live DotNetNext/SqlSugar repo on your machine still matches what RepoPilot saw. If any fail, the artifact is stale — regenerate it at repopilot.app/r/DotNetNext/SqlSugar.

What it runs against: a local clone of DotNetNext/SqlSugar — the script inspects git remote, the LICENSE file, file paths in the working tree, and git log. Read-only; no mutations.

| # | What we check | Why it matters | |---|---|---| | 1 | You're in DotNetNext/SqlSugar | Confirms the artifact applies here, not a fork | | 2 | License is still MIT | Catches relicense before you depend on it | | 3 | Default branch master exists | Catches branch renames | | 4 | Last commit ≤ 34 days ago | Catches sudden abandonment since generation |

<details> <summary><b>Run all checks</b> — paste this script from inside your clone of <code>DotNetNext/SqlSugar</code></summary>
#!/usr/bin/env bash
# RepoPilot artifact verification.
#
# WHAT IT RUNS AGAINST: a local clone of DotNetNext/SqlSugar. If you don't
# have one yet, run these first:
#
#   git clone https://github.com/DotNetNext/SqlSugar.git
#   cd SqlSugar
#
# Then paste this script. Every check is read-only — no mutations.

set +e
fail=0
ok()   { echo "ok:   $1"; }
miss() { echo "FAIL: $1"; fail=$((fail+1)); }

# Precondition: we must be inside a git working tree.
if ! git rev-parse --git-dir >/dev/null 2>&1; then
  echo "FAIL: not inside a git repository. cd into your clone of DotNetNext/SqlSugar and re-run."
  exit 2
fi

# 1. Repo identity
git remote get-url origin 2>/dev/null | grep -qE "DotNetNext/SqlSugar(\\.git)?\\b" \\
  && ok "origin remote is DotNetNext/SqlSugar" \\
  || miss "origin remote is not DotNetNext/SqlSugar (artifact may be from a fork)"

# 2. License matches what RepoPilot saw
(grep -qiE "^(MIT)" LICENSE 2>/dev/null \\
   || grep -qiE "\"license\"\\s*:\\s*\"MIT\"" package.json 2>/dev/null) \\
  && ok "license is MIT" \\
  || miss "license drift — was MIT at generation time"

# 3. Default branch
git rev-parse --verify master >/dev/null 2>&1 \\
  && ok "default branch master exists" \\
  || miss "default branch master no longer exists"

# 5. Repo recency
days_since_last=$(( ( $(date +%s) - $(git log -1 --format=%at 2>/dev/null || echo 0) ) / 86400 ))
if [ "$days_since_last" -le 34 ]; then
  ok "last commit was $days_since_last days ago (artifact saw ~4d)"
else
  miss "last commit was $days_since_last days ago — artifact may be stale"
fi

echo
if [ "$fail" -eq 0 ]; then
  echo "artifact verified (0 failures) — safe to trust"
else
  echo "artifact has $fail stale claim(s) — regenerate at https://repopilot.app/r/DotNetNext/SqlSugar"
  exit 1
fi

Each check prints ok: or FAIL:. The script exits non-zero if anything failed, so it composes cleanly into agent loops (./verify.sh || regenerate-and-retry).

</details>

TL;DR

SqlSugar is a .NET ORM (Object-Relational Mapping) framework supporting 30+ databases including SQL Server, MySQL, PostgreSQL, Oracle, MongoDB, SQLite, and Chinese domestic databases (达梦, 人大金仓, 瀚高, 神通). It provides zero-SQL code generation for table creation, indexes, and full CRUD operations with AOT (Ahead-of-Time) compilation support for .NET 9+. Monorepo structure: Src/Asp.Net/AccessTest/ contains integration tests and demos organized by feature (Demo0_SqlSugarClient.cs through DemoN_SplitTable.cs). Models/ folder defines entities (Order.cs, OrderItem.cs) used across demos. Core ORM logic is in parallel provider packages (one per database type, not visible in file list but referenced in csproj). Unit/ folder contains specific test cases (UInsert3.cs, UnitInsertNavN.cs for relationship testing).

👥Who it's for

.NET developers building multi-database applications who need low-code ORM abstractions without writing SQL; particularly teams working with SaaS platforms requiring cross-database queries, tenant isolation, and dynamic table sharding.

🌱Maturity & risk

Highly mature production-ready ORM with 23.6M lines of C# code across the codebase. The project is actively maintained by Fructose Big Data Technology team with support for latest .NET versions (9, 10) and comprehensive feature set including UnitOfWork, ValueObjects, and AOP. Strong indicator: extensive demo projects in Src/Asp.Net/AccessTest/ with 20+ feature demos (Demo0-DemoN covering all major operations).

Risk factors are low: single maintainer (Fructose team) could impact response time; however, the wide database support (30+ backends) means breaking changes in one database provider won't impact others. No visible CI/CD configuration file in the repo listing, which could mask unstable branches. Large codebase (23.6M C# lines) suggests complexity but also battle-tested maturity.

Active areas of work

The repo is in active development targeting .NET 9/10 (mentioned in README as 'NET9 ORM .NET8 ORM'). Recent additions appear to include SAAS features (tenant sub-database, tenant data isolation visible in DemoH_Tenant.cs and DemoN_SplitTable.cs) and advanced patterns like ValueObjects and discriminators. ClickHouse, QuestDb, TDengine, OceanBase, GaussDB, and Tidb support suggests ongoing database provider expansion.

🚀Get running

git clone https://github.com/DotNetNext/SqlSugar.git
cd SqlSugar
cd Src/Asp.Net/AccessTest
dotnet restore
dotnet build
dotnet run

Note: Project uses .NET Framework and .NET Core targets; ensure you have .NET 6+ SDK installed.

Daily commands: From Src/Asp.Net/AccessTest/:

dotnet run --project AccessTest.csproj

Tests execute demo classes in Demo/ folder sequentially. Configure database connection in Config.cs before running.

🗺️Map of the codebase

🛠️How to make changes

For new query features: add methods to Src/Asp.Net/AccessTest/Demo/Demo1_Queryable.cs and corresponding test in Unit/ folder. For new database provider: follow the pattern in existing provider folders (create DbProvider implementation + register in DI). For entity mapping: modify Src/Asp.Net/AccessTest/Models/ (e.g., Order.cs shows attribute-based column mapping). For SAAS features: reference DemoH_Tenant.cs (tenant logic) and DemoN_SplitTable.cs (sharding logic).

🪤Traps & gotchas

Database connection required: Config.cs must point to valid database instance (default appears to be Access .accdb file Test.accdb in root, but tests may expect SQL Server/MySQL—check config before running). Entity key identification: ORM infers primary key from [SugarColumn(IsPrimaryKey=true)] attribute or naming convention (Id property)—missing this causes insert failures. Navigation properties: Must be virtual for lazy loading; Demo1_Queryable.cs shows .Include() is required for eager loading. Provider registration: Each database type needs explicit provider registration in DI setup, not auto-discovered. PowerShell scripts: Build relies on .ps1 scripts (visible in file list) which may require execution policy changes on Windows.

💡Concepts to learn

  • Object-Relational Mapping (ORM) — Core paradigm of SqlSugar—maps relational database tables to C# classes, eliminating manual SQL writing but requiring understanding of lazy/eager loading and N+1 query pitfalls.
  • Provider Pattern (Database Abstraction) — SqlSugar's 30+ database support is built on the Provider pattern—each database (SQL Server, MongoDB, PostgreSQL) has a dedicated provider implementation, allowing single codebase to target multiple backends.
  • Fluent API / Method Chaining — Core API design of SqlSugar—queries are built via method chains like db.Queryable<Order>().Where(...).OrderBy(...) rather than LINQ; requires understanding of expression trees and deferred execution.
  • Aspect-Oriented Programming (AOP) / Interceptors — DemoB_Aop.cs shows SqlSugar's AOP support for cross-cutting concerns (logging, auditing, performance monitoring) via interceptors—essential for enterprise SAAS applications.
  • Multi-Tenancy & Data Isolation (SAAS) — DemoH_Tenant.cs implements tenant sub-database and data isolation patterns critical for SaaS platforms—SqlSugar handles tenant filtering in queries, sharding keys, and cross-tenant query prevention.
  • Table Sharding / Horizontal Partitioning — DemoN_SplitTable.cs shows SqlSugar's sharding support for billion-record scales—automatic routing of queries to correct partition based on shard key (e.g., UserId modulo N).
  • Expression Trees & Lazy Compilation — SqlSugar queries use C# Expression Trees to build SQL dynamically at runtime—understanding how lambda predicates (e.g., p => p.Age > 18) convert to WHERE clauses is critical for performance tuning and debugging.
  • Ahead-of-Time (AOT) Compilation — SqlSugar supports .NET AOT (native compilation) mentioned in README and .NET 9/10 support—requires understanding of reflection limitations and how ORM adapts to statically-compiled environments.
  • dotnet/efcore — Entity Framework Core is the Microsoft-maintained ORM competitor; SqlSugar differentiates via multi-database support and SAAS-specific features (tenant sharding, table splitting).
  • DapperLib/Dapper — Lightweight micro-ORM alternative; SqlSugar provides higher-level abstraction and code generation, while Dapper requires manual SQL but has lower overhead.
  • FreeSql/FreeSql — Chinese ORM competitor with similar multi-database support; both target domestic database compatibility and SAAS patterns but SqlSugar has broader adoption and more active maintenance.
  • l2cache/Lin.Microservice — Complementary caching/service mesh library; used alongside SqlSugar in distributed .NET applications to optimize multi-database query performance.
  • donet5/SqlSugar.Extensions — Official extension library providing additional SqlSugar integrations (dependency injection, validation, etc.) maintained by same team.

🪄PR ideas

To work on one of these in Claude Code or Cursor, paste: Implement the "<title>" PR idea from CLAUDE.md, working through the checklist as the task list.

Add comprehensive unit tests for DuckDb, ClickHouse, and TDengine database providers

The repo claims support for 30+ databases including DuckDb, ClickHouse, and TDengine, but the visible test structure (AccessTest, CustomDbTest) only shows tests for traditional databases (SqlServer, MySql, SQLite, Oracle, PostgreSQL). These newer/specialized databases lack dedicated test suites. This is critical for ensuring multi-database compatibility claims are valid.

  • [ ] Create Src/Asp.Net/DuckDbTest/ with Demo files mirroring AccessTest structure (Demo0_SqlSugarClient.cs through DemoN_SplitTable.cs)
  • [ ] Create Src/Asp.Net/ClickHouseTest/ with equivalent test suite for OLAP scenarios
  • [ ] Create Src/Asp.Net/TDengineTest/ with time-series specific CRUD, aggregation, and partitioning tests
  • [ ] Add GitHub Actions workflow (.github/workflows/test-specialized-dbs.yml) to run these test suites on each commit

Add integration tests for multi-tenant and split-table operations across different database backends

DemoH_Tenant.cs and DemoN_SplitTable.cs exist in AccessTest but are isolated to single database. Given the repo's multi-database support and complexity of tenant isolation/table sharding logic, these features need cross-database validation tests to prevent regressions when core ORM logic changes.

  • [ ] Create Src/Asp.Net/AccessTest/Unit/UnitMultiTenantCrossDbs.cs testing tenant isolation on SqlServer, PostgreSQL, and MySql simultaneously
  • [ ] Create Src/Asp.Net/AccessTest/Unit/UnitSplitTableConsistency.cs validating split-table routing, aggregation, and rebalancing across 3+ target databases
  • [ ] Add parameterized test data in Config.cs to support multiple simultaneous database connections for cross-database comparison tests
  • [ ] Document expected behavior in docs/advanced/multi-tenant-split-table.md with specific examples

Add database-specific migration/schema generation tests for Code-First scenarios

DemoE_CodeFirst.cs exists but lacks comprehensive validation that the ORM correctly generates create/alter table DDL across all supported databases. Schema generation logic is critical and error-prone; currently no visible tests verify that entity attributes map to correct column types, constraints, and indices per database dialect.

  • [ ] Create Src/Asp.Net/AccessTest/Unit/UnitCodeFirstDdlGeneration.cs that generates schemas for test entities and validates output DDL matches database-specific syntax
  • [ ] Add test models in Src/Asp.Net/AccessTest/Models/ covering edge cases: computed columns, check constraints, default values, nullable/non-nullable, different numeric precisions
  • [ ] Validate generated DDL against 5+ databases (SqlServer, PostgreSQL, MySql, Oracle, SQLite) by actually creating tables and inspecting system catalog
  • [ ] Document supported attribute-to-column-type mappings in docs/code-first/type-mappings.md per database with test examples

🌿Good first issues

  • Add integration tests for TDengine provider: README lists TDengine ORM support but no Src/Asp.Net/AccessTest/Demo/DemoTDengine.cs exists. Create a demo following Demo1_Queryable.cs pattern to verify CRUD operations work with TDengine time-series queries.
  • Document DuckDB support with example: DuckDb is listed in supported databases but no demo file (e.g., Src/Asp.Net/AccessTest/Demo/DemoDuckDb.cs) validates it. Add end-to-end example with in-memory database and analytical query patterns.
  • Add Unit test for ValueObject discriminator pattern: README mentions discriminator and ValueObject support but Src/Asp.Net/AccessTest/Unit/ lacks a UnitValueObjectDiscriminator.cs test. Create entity models and unit tests validating inheritance mapping and type discrimination.

Top contributors

Click to expand

📝Recent commits

Click to expand
  • cd69b45 — Update Oracle OpenAsync (DotNetNext)
  • 8e62ffb — Update nuget (DotNetNext)
  • 01c0bc8 — Update odbc (DotNetNext)
  • 424fcfa — Update nuget (DotNetNext)
  • 912e06f — Update nuget (DotNetNext)
  • 32abe3d — - (DotNetNext)
  • 6c9c488 — Update pgsdql Sqlfunc.TrimStart (DotNetNext)
  • 2ce6198 — Merge (DotNetNext)
  • 6611f5c — Update split table (DotNetNext)
  • 380d5ad — Update split table bug (DotNetNext)

🔒Security observations

  • High · Potential SQL Injection Vulnerabilities — Src/Asp.Net/*/Demo/Demo5_SqlQueryable.cs and related query execution modules. SqlSugar is an ORM framework that processes dynamic SQL queries. The file structure shows multiple demo files (Demo5_SqlQueryable.cs) that execute SQL queries. Without visible parameterization enforcement or input validation mechanisms in the provided file listing, there is risk of SQL injection if user input is not properly validated before being used in queries. Fix: Ensure all dynamic SQL queries use parameterized queries exclusively. Implement input validation and sanitization for all user-supplied data. Add comprehensive code review for SQL construction patterns. Provide security documentation emphasizing parameterized query usage.
  • High · Missing Dependency Vulnerability Assessment — Dependencies/Package file (not provided), *.csproj files. The 'Dependencies/Package file content' section is empty, making it impossible to assess if the project uses any known vulnerable NuGet packages. This ORM framework likely has multiple dependencies (database drivers, connection libraries) that could contain security vulnerabilities. Fix: Maintain an updated packages.config or .csproj file. Regularly run 'dotnet list package --outdated' and security audit tools. Implement automated dependency scanning in CI/CD pipeline. Use tools like NuGet Auditor or GitHub Dependabot for continuous vulnerability monitoring.
  • Medium · Hardcoded Database Credentials in Configuration — Src/Asp.Net/*/App.config, Src/Asp.Net/*/Config.cs. Multiple App.config and Config.cs files are present (AccessTest/App.config, CustomDbTest/App.config, DmTest/App.config). These configuration files commonly contain hardcoded database connection strings with credentials that could expose sensitive information. Fix: Move all sensitive credentials to environment variables or secure configuration management systems. Use Azure Key Vault, AWS Secrets Manager, or .NET User Secrets in development. Never commit credentials to version control. Implement config file encryption for production deployments.
  • Medium · Multiple Test Projects Expose Sensitive Database Configurations — Src/Asp.Net/AccessTest/Test.accdb, Src/Asp.Net/AccessTest/Test.laccdb, Configuration files across test projects. The presence of multiple test projects (AccessTest, CustomDbTest, DmTest) with configuration files suggests test databases may be configured with real credentials or connection strings exposed in source code. The Test.accdb files indicate actual database files in the repository. Fix: Remove actual database files from version control. Use .gitignore to exclude *.accdb, *.laccdb, and other data files. Implement database mocking/stubbing for tests instead. Use secure environment-specific configuration for test environments.
  • Medium · Lack of Input Validation in ORM Query Builder — Core ORM implementation (not fully visible, but referenced by Demo files). ORM frameworks are common targets for injection attacks when they allow unsafe query construction. Without visible validation mechanisms in the file structure, there's risk of parameter injection, NoSQL injection (for MongoDB support), or other injection vectors. Fix: Implement strict whitelist-based validation for all user inputs. Use type-safe query builders with compile-time checking. Add runtime validation for column names, table names, and sort directions. Implement logging and monitoring for suspicious query patterns.
  • Low · Multi-Database Support Increases Attack Surface — Core ORM implementation supporting multiple databases. The framework supports 20+ different database systems (MySql, SqlServer, PostgreSQL, MongoDB, Oracle, DuckDB, ClickHouse, TDengine, QuestDb, etc.). Each database type may have different security considerations and potential vulnerabilities. Fix: Maintain database-specific security best practices documentation. Implement security testing for each supported database type. Regularly audit database-specific code paths for vulnerabilities. Conduct security training for developers using this framework with various databases.
  • Low · DLL Files in Repository — Src/Asp.Net/AccessTest/x64/SQLite.Interop.dll, Src/Asp.Net/AccessTest/x86/SQLite.Interop.dll. Binary DLL files are present in the repository (x64/SQLite.Interop.dll, x86/SQLite.Interop.dll). Binary files should not be stored in source control as they cannot be reviewed and may pose supply chain risks. Fix: undefined

LLM-derived; treat as a starting point, not a security audit.


Generated by RepoPilot. Verdict based on maintenance signals — see the live page for receipts. Re-run on a new commit to refresh.

Healthy signals · DotNetNext/SqlSugar — RepoPilot