tursodatabase/turso · error · NotSupportedException
Turso does not support changing the active database.
Error message
Turso does not support changing the active database.
What it means
ChangeDatabase is an abstract DbConnection member every ADO.NET provider must implement; TursoConnection always throws NotSupportedException because one connection is bound to exactly one database for its lifetime (the underlying handle is opened per Data Source). There is no code path that succeeds.
Source
Thrown at bindings/dotnet/src/Turso.Data/TursoConnection.cs:167
SyncAsync(CancellationToken.None).GetAwaiter().GetResult();
}
public Task SyncAsync(CancellationToken cancellationToken = default)
{
ObjectDisposedException.ThrowIf(_disposed, this);
if (cancellationToken.IsCancellationRequested)
return Task.FromCanceled(cancellationToken);
if (State != ConnectionState.Open)
throw new InvalidOperationException("Turso database is closed.");
if (!_connectionOptions.IsReplica)
throw new NotSupportedException("Sync requires an embedded replica connection.");
throw new NotSupportedException("Embedded replica sync is not supported yet by the .NET provider.");
}
public override void ChangeDatabase(string databaseName)
{
throw new NotSupportedException("Turso does not support changing the active database.");
}
internal int DefaultTimeout => _connectionOptions.DefaultTimeout;
internal bool IsRemote => _remoteClient is not null;
internal bool ReadUncommitted
{
get => _readUncommitted;
set => _readUncommitted = value;
}
internal TursoDatabaseHandle Turso => _turso ?? throw new InvalidOperationException("Turso database is closed.");
internal async Task<RemoteStatementResult> ExecuteRemoteAsync(
string sql,
TursoParameterCollection parameters,
bool wantRows,View on GitHub (pinned to 244cde92a7)
Solutions
- Open a new TursoConnection with a different Data Source connection string instead of calling ChangeDatabase
- If generic code insists on calling it, catch NotSupportedException and fall back to a connection-per-database strategy
- Cache/pool connections keyed by database identifier to avoid reopen overhead
Example fix
// before
conn.ChangeDatabase("otherdb"); // always throws NotSupportedException
// after
using var other = new TursoConnection("Data Source=file:other.db");
other.Open(); Defensive patterns
Strategy: try-catch
Try / catch
try { conn.ChangeDatabase(name); }
catch (NotSupportedException)
{
// fall back: open a dedicated connection per database
} Prevention
- Design for connection-per-database instead of connection-per-server
- Flag TursoConnection as non-switchable in adapter capability matrices
- Key a connection pool by database name up front
When it happens
Trigger: Calling conn.ChangeDatabase("otherdb") at any time, open or closed; generic middleware (migration runners, test harnesses, ORM tooling) that calls ChangeDatabase when it wants to switch catalogs, a pattern inherited from SqlClient/MySqlConnector usage.
Common situations: Adapters written for SQL Server or MySQL where per-connection database switching is routine; multi-tenant code that reuses one pooled connection across tenants; tooling that probes multiple databases through one connection.
Related errors
- Sync requires an embedded replica connection.
- Embedded replica sync is not supported yet by the .NET provi
- Embedded replica connections are not supported yet by the .N
- Sync Interval requires embedded replica support, which is no
- A transaction is already active on this connection.
AI-assisted analysis of tursodatabase/turso@244cde92a7 (2026-08-20).
Data as JSON: /api/errors/993cc05fb08ea586.
Report an issue: GitHub.