{"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/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L1730-L1766","documentation":"Two properties mapped to the same column declare different column comments via HasComment. The physical column can carry only one comment, so EF requires them to match exactly (compared with StringComparison.Ordinal, so case and whitespace matter).","triggerScenarios":"ValidateCompatible() reads property.GetComment(storeObject) and duplicateProperty.GetComment(storeObject) (null coerced to empty); an Ordinal inequality throws. Happens when two entities sharing a column each call HasComment with different text.","commonSituations":"Documentation refresh on one entity but not its table-splitting partner; localization of comments applied to only one side; scaffolding that imported comments only for the principal entity.","solutions":["Set the identical HasComment text on both properties.","Remove HasComment from one side so both fall back to empty.","If distinct documentation is genuinely needed, remap one property to a distinct column."],"exampleFix":"// before\nmodelBuilder.Entity<Customer>().Property(c => c.Ref).HasComment(\"Customer reference\");\nmodelBuilder.Entity<CustomerFlags>().Property(f => f.Ref).HasComment(\"Customer ref\"); // shared, case/wording differs\n\n// after\nmodelBuilder.Entity<Customer>().Property(c => c.Ref).HasComment(\"Customer reference\");\nmodelBuilder.Entity<CustomerFlags>().Property(f => f.Ref).HasComment(\"Customer reference\");","handlingStrategy":"validation","validationCode":"foreach (var (col, props) in sharedColumnGroups)\n{\n    var comments = props.Select(p => p.GetComment(storeObject) ?? \"\").Distinct(StringComparer.Ordinal).ToList();\n    if (comments.Count > 1)\n        Console.WriteLine($\"Column {col} has conflicting comments\");\n}","typeGuard":null,"tryCatchPattern":"try { _ = db.Model; } catch (InvalidOperationException ex) when (ex.Message.Contains(\"different comments\")) { // align HasComment on both properties }","preventionTips":["Maintain column comments in one place; reference the same string on shared columns.","Remember comments compare case-sensitively; standardize wording.","Smoke-test the model at startup."],"tags":["model-validation","column-mapping","comment","relational"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}