{"record":{"id":"88b4504d9b94da7c","repo":"dotnet/efcore","slug":"numsortorderproperties-values-were-provided-in-c","errorCode":null,"errorMessage":"{numSortOrderProperties} values were provided in CreateIndexOperations.IsDescending, but the operation has {numColumns} columns.","messagePattern":"(.+?) values were provided in CreateIndexOperations\\.IsDescending, but the operation has (.+?) columns\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Migrations/Operations/CreateIndexOperation.cs","lineNumber":43,"sourceCode":"    /// </summary>\n    public virtual string? Schema { get; set; }\n\n    /// <summary>\n    ///     The table that contains the index.\n    /// </summary>\n    public virtual string Table { get; set; } = null!;\n\n    /// <summary>\n    ///     The ordered list of column names for the column that make up the index.\n    /// </summary>\n    public virtual string[] Columns\n    {\n        get => _columns!;\n        set\n        {\n            if (_isDescending is not null && _isDescending.Length > 0 && value.Length != _isDescending.Length)\n            {\n                throw new ArgumentException(RelationalStrings.CreateIndexOperationWithInvalidSortOrder(_isDescending.Length, value.Length));\n            }\n\n            _columns = value;\n        }\n    }\n\n    /// <summary>\n    ///     Indicates whether or not the index should enforce uniqueness.\n    /// </summary>\n    public virtual bool IsUnique { get; set; }\n\n    /// <summary>\n    ///     A set of values indicating whether each corresponding index column has descending sort order.\n    /// </summary>\n    public virtual bool[]? IsDescending\n    {\n        get => _isDescending;\n        set","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Migrations/Operations/CreateIndexOperation.cs#L25-L61","documentation":"Thrown by the CreateIndexOperation.Columns setter when IsDescending has already been set and a new columns array is assigned with a different length. Each IsDescending entry corresponds to exactly one column.","triggerScenarios":"Assigning operation.Columns after operation.IsDescending, with mismatched lengths. Common in hand-built CreateIndexOperation or reflection/codegen that sets IsDescending first.","commonSituations":"Custom migration code generators that build operations incrementally. Reflection-based migration construction. Renaming/reordering columns without re-sizing IsDescending.","solutions":["Set IsDescending AFTER Columns, or reset IsDescending to null before resizing Columns.","Ensure both arrays have the same length, one sort-order flag per column.","When building operations programmatically, set Columns first, then IsDescending."],"exampleFix":"// before\nvar op = new CreateIndexOperation { Name = \"IX_T\", Table = \"T\" };\nop.IsDescending = new[] { false, true };\nop.Columns = new[] { \"A\" }; // throws: 2 vs 1\n\n// after\nvar op = new CreateIndexOperation { Name = \"IX_T\", Table = \"T\" };\nop.Columns = new[] { \"A\", \"B\" };\nop.IsDescending = new[] { false, true };","handlingStrategy":"validation","validationCode":"static CreateIndexOperation SafeCreateIndex(string name, string table, string[] columns, bool[]? isDescending)\n{\n    if (isDescending is not null && isDescending.Length != columns.Length)\n        throw new ArgumentException(\"isDescending length must equal columns length.\");\n    return new CreateIndexOperation { Name = name, Table = table, Columns = columns, IsDescending = isDescending };\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set Columns before IsDescending on CreateIndexOperation.","Pass null for IsDescending when all columns ascend.","When building operations programmatically, derive IsDescending length from columns length."],"tags":["ef-core","migrations","createindex","argument-validation"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}