{"record":{"id":"479d1a9cc3fd7a5b","repo":"tursodatabase/turso","slug":"isolation-level-isolationlevel-is-not-supported-479d1a","errorCode":null,"errorMessage":"Isolation level {isolationLevel} is not supported.","messagePattern":"Isolation level (.+?) is not supported\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"bindings/dotnet/src/Turso.Data/TursoTransaction.cs","lineNumber":144,"sourceCode":"        _completed = true;\n    }\n\n    private void ThrowIfCompleted()\n    {\n        if (_completed)\n            throw new InvalidOperationException(\"This transaction has already completed.\");\n    }\n\n    private static IsolationLevel NormalizeIsolationLevel(IsolationLevel isolationLevel)\n    {\n        return isolationLevel switch\n        {\n            IsolationLevel.Unspecified => IsolationLevel.Serializable,\n            IsolationLevel.Serializable => IsolationLevel.Serializable,\n            IsolationLevel.ReadCommitted => IsolationLevel.Serializable,\n            IsolationLevel.RepeatableRead => IsolationLevel.Serializable,\n            IsolationLevel.ReadUncommitted => IsolationLevel.ReadUncommitted,\n            _ => throw new NotSupportedException($\"Isolation level {isolationLevel} is not supported.\")\n        };\n    }\n}\n","sourceCodeStart":126,"sourceCodeEnd":148,"githubUrl":"https://github.com/tursodatabase/turso/blob/6c7252267988c76e632af00a671e4b9788dfae13/bindings/dotnet/src/Turso.Data/TursoTransaction.cs#L126-L148","documentation":"TursoTransaction.NormalizeIsolationLevel maps several System.Transactions IsolationLevel values onto what SQLite/Turso actually supports. Most levels are coerced to Serializable, ReadUncommitted is allowed, and anything else (e.g. Chaos, Snapshot) has no mapping, so NotSupportedException is thrown.","triggerScenarios":"Beginning a TursoTransaction with BeginTransaction(IsolationLevel.Chaos) or IsolationLevel.Snapshot, or setting an unsupported level via System.Transactions.TransactionScope options that propagate into the ADO.NET provider.","commonSituations":"Porting code written for SQL Server that uses Snapshot isolation; TransactionScope configured with a non-SQLite isolation level; generic ORM code that passes through a configurable isolation level enum.","solutions":["Use IsolationLevel.Serializable (the default and fully supported) or ReadUncommitted.","Remove Snapshot/Chaos settings from TransactionScope or connection BeginTransaction calls.","Wrap the BeginTransaction call in a mapping function that converts unsupported levels to Serializable before calling the provider.","If you truly need Snapshot semantics, restructure the workload to rely on explicit transactions instead."],"exampleFix":"// before\nusing var tx = conn.BeginTransaction(IsolationLevel.Snapshot);\n\n// after\nvar level = iso == IsolationLevel.Snapshot ? IsolationLevel.Serializable : iso;\nusing var tx = conn.BeginTransaction(level);","handlingStrategy":"validation","validationCode":"// Map any unsupported level before calling the provider\nIsolationLevel Normalize(IsolationLevel iso) =>\n    iso is IsolationLevel.Serializable or IsolationLevel.ReadCommitted or\n          IsolationLevel.RepeatableRead or IsolationLevel.Unspecified\n        ? IsolationLevel.Serializable\n        : iso == IsolationLevel.ReadUncommitted ? IsolationLevel.ReadUncommitted\n        : throw new NotSupportedException($\"{iso} not supported by Turso\");","typeGuard":null,"tryCatchPattern":"try { tx = conn.BeginTransaction(iso); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"Isolation level\"))\n{\n    tx = conn.BeginTransaction(IsolationLevel.Serializable); // safe fallback\n}","preventionTips":["Always use IsolationLevel.Serializable (default) unless you specifically need ReadUncommitted.","Don't copy SQL Server TransactionScope settings (Snapshot) into SQLite-family code.","Keep a single mapping helper for isolation levels used across the app."],"tags":["dotnet","transactions","isolation-level","unsupported"],"backgroundTag":"unsupported-enum-value","analyzedSha":"6c7252267988c76e632af00a671e4b9788dfae13","analyzedAt":"2026-09-06T07:15:26.990Z","contentChangedAt":"2026-09-06T07:15:26.990Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}