{"record":{"id":"02fa740dadaed874","repo":"tursodatabase/turso","slug":"sqlite-does-not-support-sequences-see-https-go","errorCode":null,"errorMessage":"SQLite does not support sequences. See https://go.microsoft.com/fwlink/?LinkId=723262 for more information and examples.","messagePattern":"SQLite does not support sequences\\. See https://go\\.microsoft\\.com/fwlink/\\?LinkId=723262 for more information and examples\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"bindings/dotnet/src/Turso.EntityFrameworkCore.Sqlite/Update/Internal/TursoSqliteUpdateSqlGenerator.cs","lineNumber":63,"sourceCode":"    protected override ResultSetMapping AppendSelectAffectedCountCommand(\n        StringBuilder commandStringBuilder,\n        string name,\n        string? schema,\n        int commandPosition)\n    {\n        commandStringBuilder\n            .Append(\"SELECT changes()\")\n            .AppendLine(SqlGenerationHelper.StatementTerminator)\n            .AppendLine();\n\n        return ResultSetMapping.LastInResultSet | ResultSetMapping.ResultSetWithRowsAffectedOnly;\n    }\n\n    protected override void AppendRowsAffectedWhereCondition(StringBuilder commandStringBuilder, int expectedRowsAffected)\n        => commandStringBuilder.Append(\"changes() = \").Append(expectedRowsAffected);\n\n    public override string GenerateNextSequenceValueOperation(string name, string? schema)\n        => throw new NotSupportedException(SqliteStrings.SequencesNotSupported);\n\n    protected override void AppendUpdateColumnValue(\n        ISqlGenerationHelper updateSqlGeneratorHelper,\n        IColumnModification columnModification,\n        StringBuilder stringBuilder,\n        string name,\n        string? schema)\n    {\n        if (columnModification.JsonPath is not (null or \"$\"))\n        {\n            stringBuilder.Append(\"json_set(\");\n            updateSqlGeneratorHelper.DelimitIdentifier(stringBuilder, columnModification.ColumnName);\n            stringBuilder.Append(\", '\");\n            stringBuilder.Append(columnModification.JsonPath);\n            stringBuilder.Append(\"', \");\n\n            if (columnModification.Property is { IsPrimitiveCollection: false })\n            {","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/tursodatabase/turso/blob/244cde92a7df7f9b8b8b7a4075c35a12977e303e/bindings/dotnet/src/Turso.EntityFrameworkCore.Sqlite/Update/Internal/TursoSqliteUpdateSqlGenerator.cs#L45-L81","documentation":"TursoSqliteUpdateSqlGenerator.GenerateNextSequenceValueOperation throws NotSupportedException (SqliteStrings.SequencesNotSupported) whenever EF Core's update pipeline asks SQL for the next value from a sequence. SQLite has no sequence objects, so any model configuration that expects server-generated sequence values fails at SQL-generation time with a link to Microsoft's guidance.","triggerScenarios":"Configuring a key generator that needs a sequence: UseHiLo(\"seq\"), a HiLoValueGenerator, or modelBuilder.HasSequence(...); also scaffolding/reusing a model authored for the SQL Server or PostgreSQL provider where sequences or HiLo are the default key strategy.","commonSituations":"Copying an OnModelCreating from an Npgsql/SqlServer app (Npgsql defaults to HiLo on some versions); running EF migrations generated elsewhere against the Turso provider; tutorial code that assumes serial-like behavior.","solutions":["Replace UseHiLo with ValueGeneratedOnAdd (SQLite AUTOINCREMENT-style rowid keys) on the key property.","Generate keys client-side (Guid.CreateVersion7(), ULID, or a configurable base) so no server sequence is needed.","Remove modelBuilder.HasSequence(...) calls and any migration operations that create sequences.","Audit the model for HiLo/sequence conventions after switching providers — the exception surfaces at save time, not model build time."],"exampleFix":"// before\nmodelBuilder.Entity<Order>().Property(o => o.Id).UseHiLo(\"order_hilo\");\n\n// after\nmodelBuilder.Entity<Order>().Property(o => o.Id).ValueGeneratedOnAdd();","handlingStrategy":"validation","validationCode":"// fail fast at startup if the model needs sequences\nvar usesSequences = modelBuilder.Model.GetEntityTypes()\n    .SelectMany(e => e.GetProperties())\n    .Any(p => p.GetValueGenerationStrategy().ToString().Contains(\"Sequence\"));\nif (usesSequences) throw new InvalidOperationException(\"Model relies on sequences, which SQLite/Turso does not support\");","typeGuard":null,"tryCatchPattern":"try { await db.SaveChangesAsync(); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"sequences\")) { /* replace UseHiLo with ValueGeneratedOnAdd or client keys */ }","preventionTips":["Audit for UseHiLo/HasSequence whenever switching providers.","Prefer ValueGeneratedOnAdd or client-generated GUID/ULID keys for SQLite-family providers.","Run a smoke save during startup validation so this fails before production traffic."],"tags":["dotnet","ef-core","sequence","hilo","sqlite-compat"],"backgroundTag":"sequence-not-supported","analyzedSha":"244cde92a7df7f9b8b8b7a4075c35a12977e303e","analyzedAt":"2026-08-20T07:02:18.389Z","contentChangedAt":"2026-08-20T07:02:18.389Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}