{"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/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L1658-L1694","documentation":"Two properties sharing a column declare different computed-column SQL expressions via HasComputedColumnSql. Because the database can only compute one expression for the column, EF requires the expressions to match (compared case-insensitively). A mismatch would create an ambiguous migration.","triggerScenarios":"ValidateCompatible() reads property.GetComputedColumnSql(storeObject) and duplicateProperty.GetComputedColumnSql(storeObject) (null coerced to empty string) and they are not equal under OrdinalIgnoreCase.","commonSituations":"Two entities table-split on a computed column where one specifies '[Total] - [Tax]' and the other '[Net]'; copy-paste of computed SQL with subtle casing/whitespace differences; scaffolded computed columns edited inconsistently.","solutions":["Set the same HasComputedColumnSql expression (same text) on both properties.","Remove the computed SQL from one side so both fall back to the same value.","If the computations truly differ, remap one property to its own column."],"exampleFix":"// before\nmodelBuilder.Entity<Order>().Property(o => o.Net).HasComputedColumnSql(\"[Total] - [Tax]\");\nmodelBuilder.Entity<OrderSummary>().Property(s => s.Net).HasComputedColumnSql(\"[Total]-[Tax]\");\n\n// after\nmodelBuilder.Entity<Order>().Property(o => o.Net).HasComputedColumnSql(\"[Total] - [Tax]\");\nmodelBuilder.Entity<OrderSummary>().Property(s => s.Net).HasComputedColumnSql(\"[Total] - [Tax]\");","handlingStrategy":"validation","validationCode":"foreach (var (col, props) in sharedColumnGroups)\n{\n    var sqls = props.Select(p => p.GetComputedColumnSql(storeObject) ?? \"\").Distinct(StringComparer.OrdinalIgnoreCase).ToList();\n    if (sqls.Count > 1)\n        Console.WriteLine($\"Column {col} has conflicting computed-column SQL\");\n}","typeGuard":null,"tryCatchPattern":"try { _ = db.Model; } catch (InvalidOperationException ex) when (ex.Message.Contains(\"different computed values\")) { // align HasComputedColumnSql on both properties }","preventionTips":["Define computed-column SQL in one place and reuse it for every entity sharing the column.","Avoid manual whitespace/casing drift; reference a constant string.","Smoke-test the model at startup."],"tags":["model-validation","column-mapping","computed-column","relational"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}