{"record":{"id":"0300a04333b10337","repo":"dotnet/efcore","slug":"entitytype1-property1-and-entitytype2-pr-0300a0","errorCode":null,"errorMessage":"'{entityType1}.{property1}' and '{entityType2}.{property2}' are both mapped to column '{columnName}' in '{table}', but are configured to use different column orders ('{columnOrder1}' and '{columnOrder2}').","messagePattern":"'(.+?)\\.(.+?)' and '(.+?)\\.(.+?)' are both mapped to column '(.+?)' in '(.+?)', but are configured to use different column orders \\('(.+?)' and '(.+?)'\\)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs","lineNumber":1780,"sourceCode":"        if (!currentCollation.Equals(previousCollation, StringComparison.Ordinal))\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.DuplicateColumnNameCollationMismatch(\n                    duplicateProperty.DeclaringType.DisplayName(),\n                    duplicateProperty.Name,\n                    property.DeclaringType.DisplayName(),\n                    property.Name,\n                    columnName,\n                    storeObject.DisplayName(),\n                    previousCollation,\n                    currentCollation));\n        }\n\n        var currentColumnOrder = property.GetColumnOrder(storeObject);\n        var previousColumnOrder = duplicateProperty.GetColumnOrder(storeObject);\n        if (currentColumnOrder != previousColumnOrder)\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.DuplicateColumnNameOrderMismatch(\n                    duplicateProperty.DeclaringType.DisplayName(),\n                    duplicateProperty.Name,\n                    property.DeclaringType.DisplayName(),\n                    property.Name,\n                    columnName,\n                    storeObject.DisplayName(),\n                    previousColumnOrder,\n                    currentColumnOrder));\n        }\n    }\n\n    /// <summary>\n    ///     Returns the object that is used as the default value for the column the property is mapped to.\n    /// </summary>\n    /// <param name=\"property\">The property to get the default value for.</param>\n    /// <param name=\"storeObject\">The identifier of the store object.</param>\n    /// <returns>The object that is used as the default value for the column the property is mapped to.</returns>","sourceCodeStart":1762,"sourceCodeEnd":1798,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L1762-L1798","documentation":"Two properties sharing a column declare different explicit column orders via HasColumnOrder. Since they share one physical column they must agree on its position; a mismatch would generate contradictory column-ordering in migrations. Compared as plain int? inequality (null = unspecified, treated as equal).","triggerScenarios":"ValidateCompatible() reads property.GetColumnOrder(storeObject) and duplicateProperty.GetColumnOrder(storeObject); if the nullable ints differ it throws. Happens when both halves of a table-split call HasColumnOrder with different ordinals.","commonSituations":"Refactor that re-numbered columns on one entity but not its split partner; merging two separately-maintained models; scaffolded model edited to add column ordering on only one entity.","solutions":["Pass the same integer to HasColumnOrder on both properties.","Remove HasColumnOrder from one side so both leave it unspecified (null), letting conventions order them.","If the orders must differ, remap one property to its own column."],"exampleFix":"// before\nmodelBuilder.Entity<User>().Property(u => u.Email).HasColumnOrder(3);\nmodelBuilder.Entity<UserSettings>().Property(s => s.Email).HasColumnOrder(5); // shared column\n\n// after\nmodelBuilder.Entity<User>().Property(u => u.Email).HasColumnOrder(3);\nmodelBuilder.Entity<UserSettings>().Property(s => s.Email).HasColumnOrder(3);","handlingStrategy":"validation","validationCode":"foreach (var (col, props) in sharedColumnGroups)\n{\n    var orders = props.Select(p => p.GetColumnOrder(storeObject)).Distinct().ToList();\n    if (orders.Count > 1)\n        Console.WriteLine($\"Column {col} has conflicting orders: {string.Join(\", \", orders)}\");\n}","typeGuard":null,"tryCatchPattern":"try { _ = db.Model; } catch (InvalidOperationException ex) when (ex.Message.Contains(\"different column orders\")) { // align HasColumnOrder on both properties, or remove it }","preventionTips":["Prefer leaving column order unset unless a specific schema ordering is required.","If set, define it in one place and reuse on all entities sharing the column.","Smoke-test the model at startup."],"tags":["model-validation","column-mapping","column-order","relational"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}