{"record":{"id":"118463c9ce40b692","repo":"dotnet/efcore","slug":"entitytype1-property1-and-entitytype2-pr-118463","errorCode":null,"errorMessage":"'{entityType1}.{property1}' and '{entityType2}.{property2}' are both mapped to column '{columnName}' in '{table}', but are configured to use different computed values ('{value1}' and '{value2}').","messagePattern":"'(.+?)\\.(.+?)' and '(.+?)\\.(.+?)' are both mapped to column '(.+?)' in '(.+?)', but are configured to use different computed values \\('(.+?)' and '(.+?)'\\)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs","lineNumber":1676,"sourceCode":"                || (duplicateProperty.IsIndex() && duplicateProperty.GetContainingIndexes().Any(i => i.IsUnique))))\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.DuplicateColumnNameProviderTypeMismatch(\n                    duplicateProperty.DeclaringType.DisplayName(),\n                    duplicateProperty.Name,\n                    property.DeclaringType.DisplayName(),\n                    property.Name,\n                    columnName,\n                    storeObject.DisplayName(),\n                    previousProviderType.ShortDisplayName(),\n                    currentProviderType.ShortDisplayName()));\n        }\n\n        var currentComputedColumnSql = property.GetComputedColumnSql(storeObject) ?? \"\";\n        var previousComputedColumnSql = duplicateProperty.GetComputedColumnSql(storeObject) ?? \"\";\n        if (!currentComputedColumnSql.Equals(previousComputedColumnSql, StringComparison.OrdinalIgnoreCase))\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.DuplicateColumnNameComputedSqlMismatch(\n                    duplicateProperty.DeclaringType.DisplayName(),\n                    duplicateProperty.Name,\n                    property.DeclaringType.DisplayName(),\n                    property.Name,\n                    columnName,\n                    storeObject.DisplayName(),\n                    previousComputedColumnSql,\n                    currentComputedColumnSql));\n        }\n\n        var currentStored = property.GetIsStored(storeObject);\n        var previousStored = duplicateProperty.GetIsStored(storeObject);\n        if (currentStored != previousStored)\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.DuplicateColumnNameIsStoredMismatch(\n                    duplicateProperty.DeclaringType.DisplayName(),","sourceCodeStart":1658,"sourceCodeEnd":1694,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L1658-L1694","documentation":"Two properties mapped to the same column specify different computed-column SQL expressions (GetComputedColumnSql), compared case-insensitively. A physical computed column can only have one definition, so EF Core aborts finalization. Thrown from ValidateCompatible.","triggerScenarios":"Sibling TPH types where one calls HasComputedColumnSql(\"[A] + [B]\") and the other calls HasComputedColumnSql(\"[A] * 2\") on a same-named column; an owned type and owner defining different computed SQL for a shared column; table splitting where each side supplies its own formula.","commonSituations":"Refactoring a computed formula on one branch of a hierarchy without updating the sibling; introducing a computed column on the owner side while an owned entity already defines one; copy-paste of entity config that left a stale formula.","solutions":["Use identical computed-column SQL on both properties (the validator normalizes case but not whitespace).","If the formula is intentionally different, rename one column with HasColumnName.","Remove HasComputedColumnSql from one side and let the other define it (or remove from both if not needed)."],"exampleFix":"// before\nmodelBuilder.Entity<Student>().Property(s => s.Total).HasComputedColumnSql(\"[Score] + [Bonus]\");\nmodelBuilder.Entity<Teacher>().Property(t => t.Total).HasComputedColumnSql(\"[Salary] + [Bonus]\");\n// after\nmodelBuilder.Entity<Student>().Property(s => s.Total).HasComputedColumnSql(\"[Score] + [Bonus]\");\nmodelBuilder.Entity<Teacher>().Property(t => t.Total).HasColumnName(\"TeacherTotal\");","handlingStrategy":"validation","validationCode":"using (var ctx = new MyContext()) { ctx.Model.ToDebugString(); }\nvar a = ctx.Model.FindEntityType(typeof(Student))!.FindProperty(\"Total\")!.GetComputedColumnSql();\nvar b = ctx.Model.FindEntityType(typeof(Teacher))!.FindProperty(\"Total\")!.GetComputedColumnSql();\nDebug.Assert(string.Equals(a ?? \"\", b ?? \"\", StringComparison.OrdinalIgnoreCase), $\"Computed SQL mismatch: {a} vs {b}\");","typeGuard":null,"tryCatchPattern":"try { using var ctx = new MyContext(); _ = ctx.Model; }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"different computed values\"))\n{ log.Error(\"Computed-column SQL mismatch on shared column: {Msg}\", ex.Message); throw; }","preventionTips":["Define computed-column SQL once on a shared base or via a single IEntityTypeConfiguration.","Use a startup model-build test to catch computed-SQL divergence early.","Avoid copy-pasting computed SQL across siblings; reference one constant."],"tags":["ef-core","model-validation","computed-column","shared-table","column-mapping"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}