{"record":{"id":"04283b8b1ee08990","repo":"dotnet/efcore","slug":"entitytype1-property1-and-entitytype2-pr-04283b","errorCode":null,"errorMessage":"'{entityType1}.{property1}' and '{entityType2}.{property2}' are both mapped to column '{columnName}' in '{table}', but are configured with different comments ('{comment1}' and '{comment2}').","messagePattern":"'(.+?)\\.(.+?)' and '(.+?)\\.(.+?)' are both mapped to column '(.+?)' in '(.+?)', but are configured with different comments \\('(.+?)' and '(.+?)'\\)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs","lineNumber":1748,"sourceCode":"        if (!currentDefaultValueSql.Equals(previousDefaultValueSql, StringComparison.OrdinalIgnoreCase))\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.DuplicateColumnNameDefaultSqlMismatch(\n                    duplicateProperty.DeclaringType.DisplayName(),\n                    duplicateProperty.Name,\n                    property.DeclaringType.DisplayName(),\n                    property.Name,\n                    columnName,\n                    storeObject.DisplayName(),\n                    previousDefaultValueSql,\n                    currentDefaultValueSql));\n        }\n\n        var currentComment = property.GetComment(storeObject) ?? \"\";\n        var previousComment = duplicateProperty.GetComment(storeObject) ?? \"\";\n        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(),","sourceCodeStart":1730,"sourceCodeEnd":1766,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L1730-L1766","documentation":"Two properties mapped to the same column specify different database Comments (HasComment), compared ordinally. Even comments must agree on a shared column. Thrown from ValidateCompatible via GetComment(storeObject).","triggerScenarios":"Sibling TPH types where one calls HasComment(\"Student name\") and the other HasComment(\"Teacher name\") on the same column; an owned entity and owner with different comments on the shared column; table splitting where each side annotates differently.","commonSituations":"Documentation/comment annotations added independently by different teams to mirror properties; refactoring a label on one branch only; merging models from separate assemblies where comments diverge.","solutions":["Set HasComment to the identical string on both properties.","Remove HasComment from one side so both default to empty.","If comments legitimately differ, rename one column with HasColumnName."],"exampleFix":"// before\nmodelBuilder.Entity<Student>().Property(s => s.Name).HasComment(\"Student name\");\nmodelBuilder.Entity<Teacher>().Property(t => t.Name).HasComment(\"Teacher name\");\n// after\nmodelBuilder.Entity<Student>().Property(s => s.Name).HasComment(\"Person name\");\nmodelBuilder.Entity<Teacher>().Property(t => t.Name).HasComment(\"Person name\");","handlingStrategy":"validation","validationCode":"using (var ctx = new MyContext()) { ctx.Model.ToDebugString(); }\nvar a = ctx.Model.FindEntityType(typeof(Student))!.FindProperty(\"Name\")!.GetComment() ?? \"\";\nvar b = ctx.Model.FindEntityType(typeof(Teacher))!.FindProperty(\"Name\")!.GetComment() ?? \"\";\nDebug.Assert(a.Equals(b, StringComparison.Ordinal), $\"Comment mismatch: '{a}' vs '{b}'\");","typeGuard":null,"tryCatchPattern":"try { using var ctx = new MyContext(); _ = ctx.Model; }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"different comments\"))\n{ log.Error(\"Comment mismatch on shared column: {Msg}\", ex.Message); throw; }","preventionTips":["Set HasComment once via a shared IEntityTypeConfiguration.","Omit comments on derived siblings; let the declaring property own the comment.","Cover comment parity in a startup model-build test."],"tags":["ef-core","model-validation","comment","shared-table","column-mapping"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}