Configuring the database connection strings
MobilityManager separates data into a system database and one or more tenant databases. You point the application at them with two named connection strings: SystemConnection and TenantConnection. This article explains what each does and how to set them.
The two canonical connection strings
| Name | Purpose |
|---|---|
SystemConnection | System database: tenant registry, users, roles, and license. |
TenantConnection | Tenant database used for onboarding and migrations of operational data. |
The AppHost and Docker Compose both use SystemConnection and TenantConnection as the canonical names. A legacy DefaultConnection value is also recognised as a fallback for the tenant connection, but new deployments should use the canonical names.
Note: At runtime, individual tenants are resolved dynamically from a connection-string template stored in the system database.
TenantConnectionis primarily used for onboarding and applying migrations to the tenant schema.
Setting connection strings as environment variables
In configuration, connection strings live under the ConnectionStrings section. As environment variables, use the double-underscore separator:
ConnectionStrings__SystemConnection=...
ConnectionStrings__TenantConnection=...
PostgreSQL format
ConnectionStrings__SystemConnection=Host=postgres;Database=mobilitymanager_system;Username=mobilitymanager;Password=YourStrongPassword
ConnectionStrings__TenantConnection=Host=postgres;Database=mobilitymanager_tenant;Username=mobilitymanager;Password=YourStrongPassword
SQL Server format
ConnectionStrings__SystemConnection=Server=tcp:your-server,1433;Initial Catalog=MobilityManagerSystem;User ID=app;Password=secret;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;
ConnectionStrings__TenantConnection=Server=tcp:your-server,1433;Initial Catalog=MobilityManagerTenant;User ID=app;Password=secret;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;
Warning: The connection-string format must match the
DatabaseProvidervalue. A PostgreSQL string withDatabaseProvider=SqlServer(or vice versa) will fail to connect.
Where to store them by environment
- Docker Compose: the Compose files build these strings from the
POSTGRES_PASSWORDvariable and thepostgresservice host. - Kubernetes: place them in the
mobilitymanager-secretsSecret asConnectionStrings__SystemConnectionandConnectionStrings__TenantConnection, not in the ConfigMap. - Published deployment: supply them as environment variables from your process manager or secret store.
Unconfigured behaviour
If a connection string or the provider is missing, the application uses an in-memory database and shows the onboarding wizard instead of failing. Once you provide valid strings and a provider, migrations are applied on startup.
Related
- Choosing between PostgreSQL and SQL Server
- Configuring environment variables and the .env file
- Migrations and the onboarding redirect on startup
- Backing up and restoring your databases