{"record":{"id":"e160f930f6740f95","repo":"dotnet/efcore","slug":"entitytype1-property1-and-entitytype2-pr-e160f9","errorCode":null,"errorMessage":"'{entityType1}.{property1}' and '{entityType2}.{property2}' are both mapped to column '{columnName}' in '{table}', but are configured to use different stored computed column settings ('{value1}' and '{value2}').","messagePattern":"'(.+?)\\.(.+?)' and '(.+?)\\.(.+?)' are both mapped to column '(.+?)' in '(.+?)', but are configured to use different stored computed column settings \\('(.+?)' and '(.+?)'\\)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs","lineNumber":1692,"sourceCode":"        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(),\n                    duplicateProperty.Name,\n                    property.DeclaringType.DisplayName(),\n                    property.Name,\n                    columnName,\n                    storeObject.DisplayName(),\n                    previousStored,\n                    currentStored));\n        }\n\n        var hasDefaultValue = property.TryGetDefaultValue(storeObject, out var currentDefaultValue);\n        var duplicateHasDefaultValue = duplicateProperty.TryGetDefaultValue(storeObject, out var previousDefaultValue);\n        if ((hasDefaultValue\n                || duplicateHasDefaultValue)\n            && !Equals(currentDefaultValue, previousDefaultValue))\n        {\n            currentDefaultValue = GetDefaultColumnValue(property, storeObject);","sourceCodeStart":1674,"sourceCodeEnd":1710,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L1674-L1710","documentation":"Two properties sharing a column are computed columns but disagree on the 'stored' flag (GetIsStored). Stored computed columns are materialized on write; virtual ones are computed on read. The provider can only honor one setting per column, so EF rejects the model when they conflict.","triggerScenarios":"ValidateCompatible() reads property.GetIsStored(storeObject) and duplicateProperty.GetIsStored(storeObject) (both nullable bools) and they are not equal. One property called HasComputedColumnSql(sql, stored: true) and the other stored: false (or left null).","commonSituations":"One entity configured the computed column as PERSISTED (stored) and the other as virtual; scaffolded model where one side lost the stored flag during manual edits; SQL Server-specific migrations ported to another provider.","solutions":["Pass the same stored value to HasComputedColumnSql on both properties.","Decide on stored vs virtual once and apply it consistently across all entities sharing the column.","Remap one property to a distinct column if the stored requirement genuinely differs."],"exampleFix":"// before\nmodelBuilder.Entity<Balance>().Property(b => b.Total).HasComputedColumnSql(\"[Credit]-[Debit]\", stored: true);\nmodelBuilder.Entity<BalanceAudit>().Property(a => a.Total).HasComputedColumnSql(\"[Credit]-[Debit]\", stored: false);\n\n// after\nmodelBuilder.Entity<Balance>().Property(b => b.Total).HasComputedColumnSql(\"[Credit]-[Debit]\", stored: true);\nmodelBuilder.Entity<BalanceAudit>().Property(a => a.Total).HasComputedColumnSql(\"[Credit]-[Debit]\", stored: true);","handlingStrategy":"validation","validationCode":"foreach (var (col, props) in sharedColumnGroups)\n{\n    var stored = props.Select(p => p.GetIsStored(storeObject)).Distinct().ToList();\n    if (stored.Count > 1)\n        Console.WriteLine($\"Column {col} has conflicting stored-computed settings\");\n}","typeGuard":null,"tryCatchPattern":"try { _ = db.Model; } catch (InvalidOperationException ex) when (ex.Message.Contains(\"different stored computed column settings\")) { // align the stored argument of HasComputedColumnSql on both properties }","preventionTips":["Decide stored vs virtual once per computed column and apply it consistently.","Be aware that 'stored' is provider-specific (PERSISTED on SQL Server).","Smoke-test the model at startup."],"tags":["model-validation","column-mapping","computed-column","stored","relational"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}