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.
Key facts
Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.
| Field | Value |
|---|---|
| Repository | dotnetcore/SmartSql |
| Owner | dotnetcore |
| Primary language | C# |
| License | Apache-2.0 — OSI-approved |
| Stars | 1.1k |
| Forks | 228 |
| Open issues | 41 |
| Latest release | v4.2.0 (2026-05-14) |
| Last updated | 2026-07-04 |
| Source | https://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).
Get the SmartSql source
Clone the repository and explore it locally.
git clone https://github.com/dotnetcore/SmartSql.gitcd SmartSql# follow the project's README for install & configurationNeed it deployed, integrated, or customized instead? DEV.co ships production installs.
Best use cases
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.
| Signal | Assessment |
|---|---|
| Maintenance | Active |
| Documentation | Adequate |
| License clarity | Clear |
| Deployment complexity | Moderate |
| DEV.co fit | Good |
| Assessment confidence | High |
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.
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.coRelated 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?
Can SmartSql work with non-SQL databases?
What happens if a read replica is unavailable?
Is SmartSql suitable for GraphQL resolvers?
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.