Database¶
The Supabase Database module connects your EF Core DbContext to Supabase's managed PostgreSQL. It automatically builds connection strings for all three Supabase connection modes.
Overview¶
This registers AppDbContext with a connection string derived from your Supabase project URL and database credentials.
Configuration¶
{
"Deepstaging": {
"Supabase": {
"ProjectUrl": "https://your-project.supabase.co",
"Database": {
"PoolerMode": "Transaction",
"Region": "us-east-1"
}
}
}
}
dotnet user-secrets set "Deepstaging:Supabase:Database:Password" "your-db-password"
Options¶
| Property | Type | Default | Description |
|---|---|---|---|
Password |
string |
— | Database password (from Supabase dashboard → Settings → Database) |
PoolerMode |
SupabasePoolerMode |
Transaction |
Connection mode: Direct, Session, or Transaction |
Region |
string |
— | AWS region for pooled connections (e.g., us-east-1) |
Database |
string |
"postgres" |
Target database name |
ConnectionString |
string |
— | Raw connection string override (bypasses all other settings) |
Connection Modes¶
Supabase offers three ways to connect to your database:
Direct¶
Connects directly to the Postgres instance. Best for migrations, admin tasks, and long-running operations.
Note
Direct connections don't require Region. They're limited to a smaller connection pool — use pooled modes for application traffic.
Session Pooler¶
Maintains persistent connections through Supavisor. Supports prepared statements and session-level features.
Transaction Pooler¶
Shares connections across requests at the transaction level. Best for serverless and high-concurrency workloads.
Warning
Transaction pooling doesn't support prepared statements. If EF Core uses them, switch to Session mode or configure Npgsql to disable prepared statements.
Raw Connection String¶
To bypass the connection string builder entirely, provide a raw connection string:
{
"Deepstaging": {
"Supabase": {
"Database": {
"ConnectionString": "Host=db.xyz.supabase.co;Port=5432;Database=postgres;Username=postgres;Password=secret;SSL Mode=Require"
}
}
}
}
This takes precedence over all other database configuration.
Bridging to Other Providers¶
Use AddSupabaseDatabaseConnectionString to feed the Supabase connection string into other Deepstaging infrastructure services:
services.AddDeepstaging(options => options
.AddSupabaseDatabaseConnectionString<AppRuntime, DeepstagingPostgresOptions>(
(pgOpts, cs) => pgOpts.ConnectionString = cs)
.AddPostgresAuditStore()
.AddPostgresDataStore<AppRuntime, Article>());
This lets you use Supabase's managed Postgres as the backing store for Audit Trail, Data Store, Notifications, and Background Jobs — without those modules knowing anything about Supabase.