{"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/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L1762-L1798","documentation":"Two properties mapped to the same column specify different ColumnOrder values via HasColumnOrder(n). The validator needs the column to occupy one ordinal position, so EF aborts. Thrown from ValidateCompatible via GetColumnOrder(storeObject).","triggerScenarios":"Sibling TPH types where one calls HasColumnOrder(3) and the other HasColumnOrder(5) on the same column; an owned entity and owner with conflicting order values; table splitting where each side sets an explicit order for a shared column.","commonSituations":"Adding HasColumnOrder on one entity to control migration column ordering while forgetting the sibling that shares the column; merging configurations from teams that picked different ordinals; refactoring order numbers on one branch only.","solutions":["Set HasColumnOrder to the same integer on both properties sharing the column.","Remove HasColumnOrder from one side so both default to null (EF picks ordering).","Rename one column with HasColumnName if the orderings legitimately differ."],"exampleFix":"// before\nmodelBuilder.Entity<Student>().Property(s => s.Name).HasColumnOrder(3);\nmodelBuilder.Entity<Teacher>().Property(t => t.Name).HasColumnOrder(5);\n// after\nmodelBuilder.Entity<Student>().Property(s => s.Name).HasColumnOrder(3);\nmodelBuilder.Entity<Teacher>().Property(t => t.Name).HasColumnOrder(3);","handlingStrategy":"validation","validationCode":"using (var ctx = new MyContext()) { ctx.Model.ToDebugString(); }\nvar a = ctx.Model.FindEntityType(typeof(Student))!.FindProperty(\"Name\")!.GetColumnOrder();\nvar b = ctx.Model.FindEntityType(typeof(Teacher))!.FindProperty(\"Name\")!.GetColumnOrder();\nDebug.Assert(a == b, $\"ColumnOrder mismatch: {a} vs {b}\");","typeGuard":null,"tryCatchPattern":"try { using var ctx = new MyContext(); _ = ctx.Model; }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"different column orders\"))\n{ log.Error(\"Column-order mismatch on shared column: {Msg}\", ex.Message); throw; }","preventionTips":["Set HasColumnOrder only on the declaring property; do not re-specify on siblings that share the column.","Use a single IEntityTypeConfiguration to assign orders in one place.","Cover the assertion in a startup model-build test."],"tags":["ef-core","model-validation","column-order","shared-table","column-mapping"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}