{"record":{"id":"c966d180b0adce86","repo":"clockworklabs/SpacetimeDB","slug":"stdb0014","errorCode":"STDB0014","errorMessage":"{Name} is a scheduled table but doesn't have a primary key of type `ulong`.","messagePattern":"(.+?) is a scheduled table but doesn't have a primary key of type `ulong`\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"crates/bindings-csharp/Codegen/Module.cs","lineNumber":303,"sourceCode":"\n        Name = attr.Accessor ?? table.ShortName;\n        CanonicalName = attr.Name;\n        IsPublic = attr.Public;\n        IsEvent = attr.Event;\n        if (\n            attr.Scheduled is { } reducer\n            && table.GetColumnIndex(data, attr.ScheduledAt, diag) is { } scheduledAtIndex\n        )\n        {\n            try\n            {\n                Scheduled = new(reducer, scheduledAtIndex);\n                if (\n                    table.GetPrimaryKey(this) is not { } pk\n                    || table.Members[pk].Type.Name != \"ulong\"\n                )\n                {\n                    throw new InvalidOperationException(\n                        $\"{Name} is a scheduled table but doesn't have a primary key of type `ulong`.\"\n                    );\n                }\n                if (\n                    table.Members[Scheduled.ScheduledAtColumn].Type.Name != \"SpacetimeDB.ScheduleAt\"\n                )\n                {\n                    throw new InvalidOperationException(\n                        $\"{Name}.{attr.ScheduledAt} is marked with `ScheduledAt`, but doesn't have the expected type `SpacetimeDB.ScheduleAt`.\"\n                    );\n                }\n            }\n            catch (Exception e)\n            {\n                diag.Report(ErrorDescriptor.InvalidScheduledDeclaration, (data, e.Message));\n            }\n        }\n    }","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/bindings-csharp/Codegen/Module.cs#L285-L321","documentation":"STDB0014: the source generator validates tables referenced by a [Scheduled] reducer declaration. The scheduler uses the table's primary key as the schedule handle and requires it to be the C# type `ulong` (the check is an exact match on the type name). A scheduled table without a ulong primary key is reported at build time through the diagnostic and the table is left unusable.","triggerScenarios":"Declaring the scheduled table's [PrimaryKey] as uint, int, ulong? (nullable), UInt64 spelling edge cases, Identity or Uuid; omitting [PrimaryKey] entirely on a table referenced from [Scheduled(...)].","commonSituations":"Schema migration where the PK was uint to save space; copying a normal table layout into a scheduled table; renaming the PK property and dropping the attribute by accident.","solutions":["Change the scheduled table's primary key to a plain ulong: [PrimaryKey] [AutoInc] public ulong ScheduleId;","Confirm exactly one member carries [PrimaryKey] and its type is ulong (not nullable, not uint)","Rebuild the module and confirm the STDB0014 diagnostic is gone from compiler output","Model all other identifying data in non-key columns of the scheduled row"],"exampleFix":"// before\npublic struct ScheduledTask\n{\n    [PrimaryKey] public uint Id; // STDB0014\n    public ScheduledAt At;\n}\n\n// after\npublic struct ScheduledTask\n{\n    [PrimaryKey] [AutoInc] public ulong Id;\n    public ScheduledAt At;\n}","handlingStrategy":"validation","validationCode":"// Build-time contract: scheduled tables must look like this before publishing.\n// Assert in a unit test via reflection over the module assembly if you want a CI gate:\n// every type referenced by [Scheduled] must expose one [PrimaryKey] member of type ulong.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Give every scheduled table an auto-increment ulong primary key by convention","Treat STDB0014 build diagnostics as errors in CI so bad schemas never publish","Add a code-review checklist item for scheduled tables: [PrimaryKey] ulong + [ScheduledAt] ScheduleAt"],"tags":["csharp","codegen","scheduled-table","schema-validation","primary-key","spacetimedb"],"backgroundTag":"schema-validation-failed","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}