{"record":{"id":"583207320a60c2a4","repo":"dotnet/efcore","slug":"isdescending-and-alldescending-cannot-both-be-spec","errorCode":null,"errorMessage":"IsDescending and AllDescending cannot both be specified on the [Index] attribute.","messagePattern":"IsDescending and AllDescending cannot both be specified on the \\[Index\\] attribute\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Abstractions/IndexAttribute.cs","lineNumber":75,"sourceCode":"    /// <summary>\n    ///     A set of values indicating whether each corresponding index column has descending sort order.\n    /// </summary>\n    public bool[]? IsDescending\n    {\n        get;\n        set\n        {\n            if (value is not null)\n            {\n                if (value.Length != PropertyNames.Count)\n                {\n                    throw new ArgumentException(\n                        AbstractionsStrings.InvalidNumberOfIndexSortOrderValues(value.Length, PropertyNames.Count), nameof(IsDescending));\n                }\n\n                if (AllDescending)\n                {\n                    throw new ArgumentException(AbstractionsStrings.CannotSpecifyBothIsDescendingAndAllDescending);\n                }\n            }\n\n            field = value;\n        }\n    }\n\n    /// <summary>\n    ///     Whether all index columns have descending sort order.\n    /// </summary>\n    public bool AllDescending\n    {\n        get;\n        set\n        {\n            if (IsDescending is not null)\n            {\n                throw new ArgumentException(AbstractionsStrings.CannotSpecifyBothIsDescendingAndAllDescending);","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Abstractions/IndexAttribute.cs#L57-L93","documentation":"The IndexAttribute enforces mutual exclusivity between IsDescending (per-column array) and AllDescending (single boolean). The IsDescending setter checks whether AllDescending has already been set to true and rejects the assignment. This prevents conflicting sort-order specifications on the same index.","triggerScenarios":"Setting attribute.AllDescending = true first, then subsequently setting attribute.IsDescending = new[] { true, false } — the IsDescending setter detects AllDescending is true and throws.","commonSituations":"Building an IndexAttribute programmatically where code sets AllDescending earlier in a fluent/programmatic configuration flow, then later code (perhaps from a different convention or configuration source) tries to set IsDescending; merging index configurations from multiple sources.","solutions":["Choose only one: either IsDescending for per-column control or AllDescending for uniform descending order.","If you previously set AllDescending, clear it before setting IsDescending (or vice versa) — though IndexAttribute does not support unsetting, so decide upfront which property to use.","Review all configuration sources (attributes, fluent API, conventions) that touch the same index to ensure they agree on sort-order strategy."],"exampleFix":"// before\nvar attr = new IndexAttribute(\"ColA\", \"ColB\");\nattr.AllDescending = true;\nattr.IsDescending = new[] { true, false }; // throws\n\n// after\nvar attr = new IndexAttribute(\"ColA\", \"ColB\");\nattr.IsDescending = new[] { true, false }; // per-column control only","handlingStrategy":"validation","validationCode":"// Track which sort-order property has been set before assigning\nvar attribute = new IndexAttribute(\"ColA\", \"ColB\");\n// Decide upfront: use per-column or uniform\nif (wantUniformDescending)\n{\n    attribute.AllDescending = true;\n}\nelse\n{\n    attribute.IsDescending = new[] { true, false };\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never set both AllDescending and IsDescending on the same IndexAttribute instance.","Centralize index sort-order configuration in one location to avoid conflicting assignments.","If merging configurations from multiple sources, check IsDescending for null before setting AllDescending."],"tags":["ef-core","index-attribute","model-validation","configuration"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}