DEV.co
Open-Source Databases · dotnetcore

SmartSql

SmartSql is a .NET ORM that emphasizes developer control over SQL through XML-based query management, similar to MyBatis. It adds caching (in-memory and Redis), read-write splitting, dynamic repositories, and diagnostics to reduce boilerplate while keeping SQL explicit and optimizable.

Source: GitHub — github.com/dotnetcore/SmartSql
1.1k
GitHub stars
228
Forks
C#
Primary language
Apache-2.0
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositorydotnetcore/SmartSql
Ownerdotnetcore
Primary languageC#
LicenseApache-2.0 — OSI-approved
Stars1.1k
Forks228
Open issues41
Latest releasev4.2.0 (2026-05-14)
Last updated2026-07-04
Sourcehttps://github.com/dotnetcore/SmartSql

What SmartSql is

C# ORM inspired by MyBatis that uses XML to define and filter SQL statements, supporting multiple databases (MySQL, PostgreSQL, Oracle, SQL Server, SQLite). Includes built-in caching strategies (LRU, FIFO, Redis), configurable read-write splitting, dynamic proxy-based repository generation, type handlers, and ID generation (Snowflake).

Quickstart

Get the SmartSql source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/dotnetcore/SmartSql.gitcd SmartSql# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

SQL-First Development with Performance Control

Teams that prefer explicit SQL over LINQ, especially in complex query scenarios where hand-tuned SQL is critical and visibility into generated queries is non-negotiable.

Microservices Requiring Read-Write Splitting

Applications needing built-in master-slave replication support with weighted read routing without additional abstraction layers or custom middleware.

High-Performance Applications with Multi-Level Caching

Systems requiring distributed caching strategies (Redis) combined with local in-memory caches (LRU/FIFO) with fine-grained, per-query cache management.

Implementation considerations

  • XML configuration for SQL requires discipline; establish naming conventions and validation rules early to prevent configuration drift across teams.
  • Dynamic Repository generation depends on naming conventions between C# interface methods and XML statement IDs—violations are silent until runtime.
  • Read-write splitting configuration assumes proper master-slave topology; misconfiguration can cause consistency issues or unintended write forwarding.
  • Type handlers and custom filters require understanding of SmartSql's request pipeline; overly complex custom types may cause performance degradation.
  • Cache invalidation strategy (flush on execute, time intervals) must be explicitly designed per statement; stale cache risks are higher than implicit ORM tracking.

When to avoid it — and what to weigh

  • Heavy LINQ Query Dependency — If your team is committed to LINQ-based query composition and dynamic query building, switching to XML-managed SQL requires significant refactoring and mind-shift.
  • Minimal SQL Expertise on Team — XML-based SQL management and manual query optimization demand SQL fluency; teams relying on ORM to abstract SQL complexity will struggle with maintenance.
  • Rapid Schema Evolution Required — High-velocity schema changes without SQL review cycles may be slower—XML updates require validation and testing rather than auto-generated LINQ adjustments.
  • Strong Integration with Entity Framework Ecosystem — If your codebase heavily depends on EF migrations, shadow properties, change tracking, or EF-specific plugins, SmartSql's different paradigm will introduce friction.

License & commercial use

Licensed under Apache License 2.0, a permissive OSI-approved open-source license.

Apache 2.0 permits commercial use, modification, and distribution with attribution. No royalties or restrictions on commercial deployment. However, ensure your team reviews the full license text and any third-party dependency licenses before production use; always consult legal counsel for compliance in your jurisdiction.

DEV.co evaluation signals

Editorial assessment — not user reviews. Directional, with an explicit confidence level.

SignalAssessment
MaintenanceActive
DocumentationAdequate
License clarityClear
Deployment complexityModerate
DEV.co fitGood
Assessment confidenceHigh
Security considerations

No explicit security audit or disclosure policy mentioned in provided data. Standard SQL injection mitigation applies (parameterized queries via @parameter syntax). Redis cache connections should use TLS in production. Type handlers and custom filters are user-implemented; unsafe deserialization or SQL concatenation risks exist if developers bypass parameterization. XML configuration files should be protected from unauthorized modification. Requires security review before high-sensitivity deployments.

Alternatives to consider

Entity Framework Core

Full ORM with LINQ integration, automatic change tracking, migrations, and scaffolding—trade-off is less explicit SQL control and potential performance mysteries in complex queries.

Dapper

Lightweight micro-ORM emphasizing SQL + DataReader mapping with minimal overhead; lacks SmartSql's caching, R/W splitting, and dynamic repository features but has lighter cognitive load.

MyBatis.NET (archived) / SqlSugar

SqlSugar provides similar XML/code-based SQL management with additional LINQ support; more actively maintained in recent years and larger Chinese ecosystem adoption.

Software development agency

Build on SmartSql with DEV.co software developers

If your team prioritizes SQL performance and explicit query control, SmartSql may reduce boilerplate while preserving visibility. Request a technical review of your use case, caching strategy, and R/W splitting topology to validate fit.

Talk to DEV.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

Related on DEV.co

Explore the category and the services that help you build with it.

SmartSql FAQ

Does SmartSql auto-generate migrations?
No. SmartSql manages queries, not schema. Use external tools (Flyway, DbUp, custom SQL scripts) for migrations. SmartCode companion tool can scaffold repository code, not migrations.
Can SmartSql work with non-SQL databases?
No. SmartSql is SQL-centric. It supports MySQL, PostgreSQL, Oracle, SQL Server, SQLite—relational databases only. Not suitable for NoSQL or document stores.
What happens if a read replica is unavailable?
Behavior depends on configuration. If no fallback is specified, requests may fail. Weight-based routing and health-check configuration are not detailed in provided data—requires documentation review.
Is SmartSql suitable for GraphQL resolvers?
Yes, with caveats. Dynamic Repository and query-by-ID patterns align well. However, N+1 query risks are high without explicit batching; caching strategy must be designed per resolver.

Software developers & web developers for hire

Need help beyond evaluating SmartSql? DEV.co is a software development agency offering software development services and web development for teams of every size. Our software developers and web developers build custom software, web applications, APIs, and open-source databases integrations — and maintain them long-term.

Evaluate SmartSql for Your .NET Application

If your team prioritizes SQL performance and explicit query control, SmartSql may reduce boilerplate while preserving visibility. Request a technical review of your use case, caching strategy, and R/W splitting topology to validate fit.