--- title: "Database Providers" description: "Multi-database support for SQLite, SQL Server, PostgreSQL, and MySQL" canonical: "https://roomsharp.dev/docs/v0.5.3/database-providers" source: "src/content/v0.5.3/database-providers.mdx" --- # Database Providers Multi-database support for SQLite, SQL Server, PostgreSQL, and MySQL. ## Overview RoomSharp supports multiple database providers through a unified API. Switch providers with a single builder method call. ## Supported Providers | Provider | NuGet Package | Status | |----------|---------------|--------| | SQLite | `RoomSharp` | ✓ Fully Supported | | SQL Server | `RoomSharp.SqlServer` | ✓ Fully Supported | | PostgreSQL | `RoomSharp.PostgreSql` | ✓ Fully Supported | | MySQL/MariaDB | `RoomSharp.MySql` | ✓ Fully Supported | ## SQLite ### Installation ```bash dotnet add package RoomSharp ``` ### Configuration ```csharp var db = RoomDatabase.Builder() .UseSqlite("app.db") // File path .SetJournalMode(JournalMode.WAL) .EnableMultiInstanceInvalidation() .Build(); ``` ### SQLite-Specific Features - **Journal Modes:** DELETE, WAL, MEMORY, OFF - **Multi-Instance:** Enable for concurrent access - **Type Affinity:** INTEGER, TEXT, REAL, BLOB, NULL ## SQL Server ### Installation ```bash dotnet add package RoomSharp.SqlServer ``` ### Configuration ```csharp var db = RoomDatabase.Builder() .UseSqlServer("Server=localhost;Database=MyApp;Trusted_Connection=True;") .Build(); ``` ## PostgreSQL ### Installation ```bash dotnet add package RoomSharp.PostgreSql ``` ### Configuration ```csharp var db = RoomDatabase.Builder() .UsePostgreSql("Host=localhost;Database=myapp;Username=postgres;Password=xxx") .Build(); ``` ## MySQL/MariaDB ### Installation ```bash dotnet add package RoomSharp.MySql ``` ### Configuration ```csharp var db = RoomDatabase.Builder() .UseMySql("Server=localhost;Database=myapp;Uid=root;Pwd=xxx;") .Build(); ``` ## Switching Providers Switch providers by changing a single line: ```csharp // Development: SQLite var db = RoomDatabase.Builder() .UseSqlite("dev.db") .Build(); // Production: PostgreSQL var db = RoomDatabase.Builder() .UsePostgreSql(Configuration.GetConnectionString("Production")) .Build(); ``` ## Provider-Specific Considerations ### Boolean Handling - **SQLite:** Stored as INTEGER (0/1) - **SQL Server:** Native BIT type - **PostgreSQL:** Native BOOLEAN - **MySQL:** TINYINT(1) ### Auto-Increment - **SQLite:** AUTOINCREMENT keyword - **SQL Server:** IDENTITY - **PostgreSQL:** SERIAL or GENERATED AS IDENTITY - **MySQL:** AUTO_INCREMENT ## Best Practices - Use connection strings from configuration - Test with your target database provider - Be aware of SQL dialect differences - Use standard SQL when possible for portability - Consider using different providers for dev/test/prod ## Next Steps - [Installation](/docs/v0.5.3/installation) - Install provider packages - [Performance Notes](/docs/v0.5.3/performance) - Provider performance tips - [Error Handling](/docs/v0.5.3/error-handling) - Provider-specific errors