{"record":{"id":"e769ecbf282338a3","repo":"dotnet/efcore","slug":"entitytype1-property1-and-entitytype2-pr-e769ec","errorCode":null,"errorMessage":"'{entityType1}.{property1}' and '{entityType2}.{property2}' are both mapped to column '{columnName}' in '{table}', but are configured to use different collations ('{collation1}' and '{collation2}').","messagePattern":"'(.+?)\\.(.+?)' and '(.+?)\\.(.+?)' are both mapped to column '(.+?)' in '(.+?)', but are configured to use different collations \\('(.+?)' and '(.+?)'\\)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs","lineNumber":1764,"sourceCode":"        if (!currentComment.Equals(previousComment, StringComparison.Ordinal))\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.DuplicateColumnNameCommentMismatch(\n                    duplicateProperty.DeclaringType.DisplayName(),\n                    duplicateProperty.Name,\n                    property.DeclaringType.DisplayName(),\n                    property.Name,\n                    columnName,\n                    storeObject.DisplayName(),\n                    previousComment,\n                    currentComment));\n        }\n\n        var currentCollation = property.GetCollation(storeObject) ?? \"\";\n        var previousCollation = duplicateProperty.GetCollation(storeObject) ?? \"\";\n        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(),","sourceCodeStart":1746,"sourceCodeEnd":1782,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L1746-L1782","documentation":"Two properties mapped to the same column specify different Collations (HasCollation), compared ordinally. A physical column has one collation, so EF aborts when they disagree. Thrown from ValidateCompatible via GetCollation(storeObject).","triggerScenarios":"Sibling TPH types where one calls UseCollation(\"SQL_Latin1_General_CP1_CI_AS\") on the property and the other uses a different collation or none on the same column; an owned entity and owner with mismatched collations; table splitting with divergent collation config.","commonSituations":"Adding case-sensitive comparison to one entity's code column while the sibling stays case-insensitive; cross-database porting where collation names changed on one side; using property-level UseCollation vs entity-level UseCollation inconsistently.","solutions":["Set UseCollation to the same collation name on both properties (or remove it from both).","Rename one column via HasColumnName so the collations need not match.","Split one entity into its own table."],"exampleFix":"// before\nmodelBuilder.Entity<Student>().Property(s => s.Code).UseCollation(\"SQL_Latin1_General_CP1_CS_AS\");\nmodelBuilder.Entity<Teacher>().Property(t => t.Code).UseCollation(\"SQL_Latin1_General_CP1_CI_AS\");\n// after\nmodelBuilder.Entity<Student>().Property(s => s.Code).UseCollation(\"SQL_Latin1_General_CP1_CI_AS\");\nmodelBuilder.Entity<Teacher>().Property(t => t.Code).UseCollation(\"SQL_Latin1_General_CP1_CI_AS\");","handlingStrategy":"validation","validationCode":"using (var ctx = new MyContext()) { ctx.Model.ToDebugString(); }\nvar a = ctx.Model.FindEntityType(typeof(Student))!.FindProperty(\"Code\")!.GetCollation() ?? \"\";\nvar b = ctx.Model.FindEntityType(typeof(Teacher))!.FindProperty(\"Code\")!.GetCollation() ?? \"\";\nDebug.Assert(a.Equals(b, StringComparison.Ordinal), $\"Collation mismatch: {a} vs {b}\");","typeGuard":null,"tryCatchPattern":"try { using var ctx = new MyContext(); _ = ctx.Model; }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"different collations\"))\n{ log.Error(\"Collation mismatch on shared column: {Msg}\", ex.Message); throw; }","preventionTips":["Set collation once via a shared configuration; do not override per derived type.","Prefer entity-level UseCollation over property-level when the whole entity shares a table.","Cover collation parity in a startup model-build test."],"tags":["ef-core","model-validation","collation","shared-table","column-mapping"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}