{"record":{"id":"7c526292bab9cebf","repo":"elsa-workflows/elsa-core","slug":"unsupported-persistence-column-type","errorCode":null,"errorMessage":"Unsupported persistence column type.","messagePattern":"Unsupported persistence column type\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Persistence.VNext.SqlServer/SqlServerTypeMapper.cs","lineNumber":17,"sourceCode":"using Elsa.Persistence.VNext.Relational;\n\nnamespace Elsa.Persistence.VNext.SqlServer;\n\npublic class SqlServerTypeMapper : IRelationalTypeMapper\n{\n    public string Map(PersistenceColumn column)\n    {\n        return column.Type switch\n        {\n            PersistenceColumnType.Int32 => \"int\",\n            PersistenceColumnType.Int64 => \"bigint\",\n            PersistenceColumnType.Boolean => \"bit\",\n            PersistenceColumnType.DateTimeOffset => \"datetimeoffset\",\n            PersistenceColumnType.Text or PersistenceColumnType.Json => \"nvarchar(max)\",\n            PersistenceColumnType.String => column.Length is { } length ? $\"nvarchar({length})\" : \"nvarchar(max)\",\n            _ => throw new ArgumentOutOfRangeException(nameof(column), column.Type, \"Unsupported persistence column type.\")\n        };\n    }\n}\n","sourceCodeStart":1,"sourceCodeEnd":21,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Persistence.VNext.SqlServer/SqlServerTypeMapper.cs#L1-L21","documentation":"SqlServerTypeMapper.Map translates a PersistenceColumnType to a SQL Server type string via a switch expression. The default arm throws ArgumentOutOfRangeException with the column type when a PersistenceColumnType value has no SQL Server mapping, meaning the mapper and the column-type enum are out of sync (a new enum member was added without updating this mapper).","triggerScenarios":"Schema generation encounters a PersistenceColumnType value not covered by the switch (e.g. a newly added enum member like Guid/Decimal not yet mapped), typically after upgrading the persistence abstractions package while the SqlServer provider is older, or passing a column with an invalid/default enum value.","commonSituations":"Mixed package versions after a partial upgrade (abstractions newer than the SqlServer provider); custom column types contributed by an extension; a bug where column.Type was never assigned.","solutions":["Align package versions so Elsa.Persistence.VNext.SqlServer matches the abstractions package that defines PersistenceColumnType.","Add a mapping arm for the new PersistenceColumnType member in SqlServerTypeMapper.Map.","Verify the column's Type was set correctly upstream (default(enum) or an unmapped custom value will land in the default arm)."],"exampleFix":"// before\n_ => throw new ArgumentOutOfRangeException(nameof(column), column.Type, \"Unsupported persistence column type.\")\n// after\nPersistenceColumnType.Guid => \"uniqueidentifier\",\nPersistenceColumnType.Decimal => \"decimal(38, 10)\",\n_ => throw new ArgumentOutOfRangeException(nameof(column), column.Type, \"Unsupported persistence column type.\")","handlingStrategy":"type-guard","validationCode":"static readonly HashSet<PersistenceColumnType> Mapped =\n    new() { Int32, Int64, Boolean, DateTimeOffset, Text, Json, String };\nif (!Mapped.Contains(column.Type))\n    throw new NotSupportedException($\"{column.Type} has no SQL Server mapping.\");","typeGuard":"bool IsMappable(PersistenceColumnType type) => type is\n    PersistenceColumnType.Int32 or PersistenceColumnType.Int64 or\n    PersistenceColumnType.Boolean or PersistenceColumnType.DateTimeOffset or\n    PersistenceColumnType.Text or PersistenceColumnType.Json or PersistenceColumnType.String;","tryCatchPattern":"try { var sqlType = mapper.Map(column); }\ncatch (ArgumentOutOfRangeException ex) { logger.LogError(ex, \"Unmapped column type {Type}\", ex.ActualValue); }","preventionTips":["Keep the abstractions and SqlServer provider packages on the same version.","When adding a PersistenceColumnType member, update every provider's type mapper in the same change.","Always assign column.Type explicitly; never rely on default(enum)."],"tags":["sqlserver","schema","enum","csharp"],"backgroundTag":"unsupported-enum-value","analyzedSha":"fe9217bdfa0e27f0e09e45006eb6898f616e513d","analyzedAt":"2026-09-13T20:32:34.702Z","contentChangedAt":"2026-09-13T20:32:34.702Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}