tursodatabase/turso · error · ArgumentException
Unknown collection: {collectionName}.
Error message
Unknown collection: {collectionName}. What it means
GetSchema(collectionName) only recognizes a fixed set of metadata collections: MetaDataCollections, ReservedWords, Tables, and Columns (DataSourceInformation and DataTypes are not implemented in this provider, unlike Microsoft.Data.Sqlite). Any other collectionName throws ArgumentException. The MetaDataCollections table returned by GetSchema() lists exactly what is supported, including the number of restrictions per collection (Tables and Columns: 4; the rest: 0).
Source
Thrown at bindings/dotnet/src/Turso.Data.Sqlite/SqliteConnection.cs:320
if (string.Equals(collectionName, DbMetaDataCollectionNames.ReservedWords, StringComparison.OrdinalIgnoreCase))
{
ValidateRestrictions(collectionName, restrictionValues, 0);
var table = new DataTable(DbMetaDataCollectionNames.ReservedWords);
table.Columns.Add(DbMetaDataColumnNames.ReservedWord, typeof(string));
foreach (var word in new[] { "ABORT", "ALTER", "CREATE", "DELETE", "DROP", "INSERT", "SELECT", "UPDATE" })
table.Rows.Add(word);
return table;
}
if (string.Equals(collectionName, "Tables", StringComparison.OrdinalIgnoreCase))
return GetTablesSchema(collectionName, restrictionValues);
if (string.Equals(collectionName, "Columns", StringComparison.OrdinalIgnoreCase))
return GetColumnsSchema(collectionName, restrictionValues);
throw new ArgumentException(Properties.Resources.UnknownCollection(collectionName));
}
public static void ClearAllPools()
{
}
public static void ClearPool(SqliteConnection connection)
{
ArgumentNullException.ThrowIfNull(connection);
}
public new virtual SqliteTransaction BeginTransaction()
=> BeginTransaction(IsolationLevel.Unspecified);
public virtual SqliteTransaction BeginTransaction(bool deferred)
=> BeginTransaction(IsolationLevel.Unspecified, deferred);
public new virtual SqliteTransaction BeginTransaction(IsolationLevel isolationLevel)View on GitHub (pinned to 6c72522679)
Solutions
- Call GetSchema() (no arguments) first and read the returned collection names; request only collections in that list.
- For metadata not exposed (indexes, FKs, views, triggers), query SQLite's catalog directly: 'SELECT * FROM sqlite_master' and PRAGMA statements (index_list, foreign_key_list).
- Wrap GetSchema in a helper that catches ArgumentException and falls back to sqlite_master queries.
Example fix
// before
var tbl = conn.GetSchema("ForeignKeys"); // throws: Unknown collection: ForeignKeys
// after
var tbl = conn.GetSchema("Tables"); // supported: MetaDataCollections, ReservedWords, Tables, Columns
// for anything else, use the catalog:
using var cmd = conn.CreateCommand();
cmd.CommandText = "SELECT name, sql FROM sqlite_master WHERE type = 'table'"; Defensive patterns
Strategy: validation
Validate before calling
static readonly HashSet<string> SupportedCollections = new(StringComparer.OrdinalIgnoreCase)
{ "MetaDataCollections", "ReservedWords", "Tables", "Columns" };
static DataTable SafeGetSchema(SqliteConnection conn, string collection, string?[]? restrictions = null)
{
if (!SupportedCollections.Contains(collection))
throw new ArgumentOutOfRangeException(nameof(collection), $"{collection} not supported; query sqlite_master instead.");
return conn.GetSchema(collection, restrictions);
} Type guard
static bool IsSupportedSchemaCollection(string name) =>
name.Equals("MetaDataCollections", StringComparison.OrdinalIgnoreCase)
|| name.Equals("ReservedWords", StringComparison.OrdinalIgnoreCase)
|| name.Equals("Tables", StringComparison.OrdinalIgnoreCase)
|| name.Equals("Columns", StringComparison.OrdinalIgnoreCase); Try / catch
null
Prevention
- Enumerate GetSchema().Rows once at startup and cache the supported collection names.
- Route unsupported metadata needs to sqlite_master and PRAGMA queries (index_list, foreign_key_list).
- Do not assume Microsoft.Data.Sqlite's collection set transfers to this provider.
When it happens
Trigger: conn.GetSchema("Indexes"), GetSchema("ForeignKeys"), GetSchema("Views"), or GetSchema("DataSourceInformation"); generic schema-exploration tools (e.g. DataSet designers, SSDL generators, DB tooling) enumerating standard DbMetaDataCollectionNames; code ported from Microsoft.Data.Sqlite or System.Data.SqlClient expecting the full collection set.
Common situations: ORM/tooling compatibility layers that request standard collections, visual designers inspecting databases, and shared helpers written against richer providers.
Related errors
- Too many restrictions specified for collection {collectionNa
- Encryption is not supported by {libraryName}.
- Missing parameter values for {parameters}.
- Parameter name {parameterName} is ambiguous.
- Cannot access a disposed object. Object name: 'AggregateInv
AI-assisted analysis of tursodatabase/turso@6c72522679 (2026-08-20).
Data as JSON: /api/errors/a8c9be3ae4f27b75.
Report an issue: GitHub.