Database Providers Overview
Switch between SQL Server, PostgreSQL, SQLite, and other database providers in AuthScape.
AuthScape supports multiple database providers through Entity Framework Core. The provider is automatically detected from your connection string format, so you don't need to specify it explicitly.
Supported Providers
| Provider | Status | Use Case |
|---|---|---|
| SQL Server | Supported | Production workloads, enterprise |
| PostgreSQL | Supported | Open source, cloud-native |
| SQLite | Supported | Development, testing, small apps |
| MySQL | Coming Soon | Waiting for .NET 10 compatible Pomelo |
Auto-Detection
AuthScape analyzes your connection string to determine which database provider to use:
// Automatically uses SQL Server"DatabaseContext": "Server=localhost;Database=AuthScape;Trusted_Connection=true;"// Automatically uses PostgreSQL"DatabaseContext": "Host=localhost;Database=authscape;Username=postgres;Password=pass"// Automatically uses SQLite"DatabaseContext": "Data Source=AuthScape.db"
How It Works
The DatabaseProviderExtensions.DetectProvider() method examines your connection string for provider-specific patterns:
SQLite Detection:
- Contains
Data Source=with.dbextension - Contains
:memory:orMode=Memory
PostgreSQL Detection:
- Contains
Host=withUsername=orPassword=
SQL Server Detection (Default):
- Contains
Server=withUser Id=orTrusted_Connection= - Contains Azure SQL patterns (
.database.windows.net) - Contains SQL Express patterns (
\SQLEXPRESS)
Configuration
In appsettings.json
{"AppSettings": {"DatabaseContext": "Your connection string here"}}
Programmatic Configuration
// Using AppSettings (recommended)services.AddAuthScapeDatabase(appSettings);// Using connection string directlyservices.AddAuthScapeDatabase(connectionString);// With optionsservices.AddAuthScapeDatabase(appSettings,enableSensitiveDataLogging: false,useOpenIddict: true,lifetime: ServiceLifetime.Scoped);
Retry Policies
SQL Server and PostgreSQL connections include automatic retry policies:
- Max Retry Count: 10 attempts
- Max Retry Delay: 30 seconds
- Handles: Transient network failures, connection timeouts
SQLite does not include retry policies as it's file-based.
Migrations
Entity Framework Core migrations work with all supported providers. However, you may need provider-specific migration files:
# Generate migration for SQL Serverdotnet ef migrations add InitialCreate# Apply migrationsdotnet ef database update
Switching Providers
To switch database providers:
- Update your connection string in
appsettings.json - Generate new migrations for the target provider (if needed)
- Run the migrations
- Restart your application
The provider will be automatically detected from the new connection string.
Next Steps
- SQL Server - SQL Server connection strings
- PostgreSQL - PostgreSQL connection strings
- SQLite - SQLite for development