⚠️ Preview Release: RoomSharp is currently in Preview. Full source code will be published after the Preview stage. Learn more →
Compile-time ORM for modern .NET

Ship production-grade DAOs without runtime reflection.

RoomSharp generates type-safe data access code at build time, keeping your C# models and SQL aligned while staying multi-provider friendly.

Preview build Source Generators SQLite · SQL Server · PostgreSQL · MySQL
NuGet downloads
RoomSharp + providers (live)
Batch insert speedup
2-5x
Benchmark-proven vs baseline
Generated DAO Zero reflection Transactions built-in
RoomSharp architecture diagram

Why Choose RoomSharp?

Source-Generated DAOs

Compile-time code generation eliminates runtime reflection. No IL weaving, just pure compiled C# for maximum performance.

Multi-Database Support

Common abstractions over SQLite, SQL Server, PostgreSQL, and MySQL. Switch providers with a single builder method call.

Ultra-Fast Batch Inserts

2-5X faster than baseline with zero allocations in hot loops. Prepared statement reuse for maximum throughput.

Transaction Support

Built-in transaction helpers with automatic rollback on exceptions. Use [Transaction] attribute for clean, type-safe code.

Type Converters

Custom type mapping with ITypeConverter. Store complex types as JSON, serialize enums, or transform data however you need.

Migrations Built-In

Combine handwritten migrations with auto-migration metadata. Fallback to destructive mode for development databases.

See It in Action

C# - Entity
[Entity(TableName = "users")]
[Index(Value = ["Email"], Unique = true)]
public class User
{
    [PrimaryKey(AutoGenerate = true)]
    public long Id { get; set; }

    [Unique]
    public required string Email { get; set; }
    
    public string? Name { get; set; }
}
C# - DAO Interface
[Dao]
public interface IUserDao
{
    [Insert] 
    long Insert(User user);

    [Query("SELECT * FROM users WHERE Email = :email")]
    Task<User?> FindByEmailAsync(string email);

    [Transaction]
    async Task<long> UpsertAsync(User user)
    {
        var existing = await FindByEmailAsync(user.Email);
        if (existing is null)
            return Insert(user);
        
        existing.Name = user.Name;
        Update(existing);
        return existing.Id;
    }
}
C# - Database Setup
[Database(Version = 1, Entities = [typeof(User)])]
public abstract class AppDatabase(
    IDatabaseProvider provider, 
    ILogger? logger = null) 
    : RoomDatabase(provider, logger)
{
    public abstract IUserDao UserDao { get; }
}
C# - Usage
var db = RoomDatabase.Builder<AppDatabaseImpl>()
    .UseSqlite("app.db")
    .SetJournalMode(JournalMode.WAL)
    .EnableMultiInstanceInvalidation()
    .SetAutoCloseTimeout(TimeSpan.FromMinutes(5))
    .Build();

var userId = db.UserDao.Insert(
    new User { Email = "john@acme.dev", Name = "John" }
);

var user = await db.UserDao.FindByEmailAsync("john@acme.dev");

RoomSharp vs Alternatives

Feature RoomSharp Dapper Entity Framework Core
Compile-Time Code Generation
Zero Runtime Reflection
IL-Based Mapping
High-Performance Batch Insert Partial
Type-Safe Queries
Multi-Database Support
Migration System
Low Memory Allocations

Performance That Speaks for Itself

2-5x
Faster Than Baseline Batch Inserts
Zero
Allocations in Hot Loops
~2.5x
Faster Queries vs Dapper

Get Started in Minutes

Install via NuGet

Choose the provider package for your database:

Bash
# Core package (includes SQLite)
dotnet add package RoomSharp

# SQL Server
dotnet add package RoomSharp.SqlServer

# PostgreSQL
dotnet add package RoomSharp.PostgreSql

# MySQL/MariaDB
dotnet add package RoomSharp.MySql

# Dependency Injection (Optional)
dotnet add package RoomSharp.DependencyInjection