{"record":{"id":"a3243dfac697a163","repo":"dotnet/efcore","slug":"entitytype1-property1-and-entitytype2-pr-a3243d","errorCode":null,"errorMessage":"'{entityType1}.{property1}' and '{entityType2}.{property2}' are both mapped to column '{columnName}' in '{table}', but are configured to use different default values ('{value1}' and '{value2}').","messagePattern":"'(.+?)\\.(.+?)' and '(.+?)\\.(.+?)' are both mapped to column '(.+?)' in '(.+?)', but are configured to use different default values \\('(.+?)' and '(.+?)'\\)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs","lineNumber":1715,"sourceCode":"                    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);\n            previousDefaultValue = GetDefaultColumnValue(duplicateProperty, storeObject);\n\n            if (!Equals(currentDefaultValue, previousDefaultValue))\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                        previousDefaultValue ?? \"NULL\",\n                        currentDefaultValue ?? \"NULL\"));\n            }\n        }\n\n        var currentDefaultValueSql = property.GetDefaultValueSql(storeObject) ?? \"\";\n        var previousDefaultValueSql = duplicateProperty.GetDefaultValueSql(storeObject) ?? \"\";\n        if (!currentDefaultValueSql.Equals(previousDefaultValueSql, StringComparison.OrdinalIgnoreCase))\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.DuplicateColumnNameDefaultSqlMismatch(","sourceCodeStart":1697,"sourceCodeEnd":1733,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L1697-L1733","documentation":"Two properties sharing a column declare different resolved default VALUES (HasDefaultValue). The validator first checks whether either side has a default and, if so, resolves both to effective values (including CLR defaults via GetDefaultColumnValue) and compares them. A mismatch would generate contradictory DEFAULT constraints in migrations, so EF rejects the model.","triggerScenarios":"ValidateCompatible() calls TryGetDefaultValue on both properties; if either returns true and the resolved values (after GetDefaultColumnValue fallback) are not Equal, it throws. Thrown from the DuplicateColumnNameDefaultSqlMismatch resource with the resolved values.","commonSituations":"Owned entity and owner both set HasDefaultValue(0) vs HasDefaultValue(1) on a shared Status column; one side relies on the CLR default while the other sets an explicit default; refactor that split a column but kept inconsistent defaults.","solutions":["Call HasDefaultValue(<same-value>) on both properties.","Drop HasDefaultValue from one side so both resolve to the same effective value.","Use HasDefaultValueSql on both instead of HasDefaultValue, or remap one property to its own column."],"exampleFix":"// before\nmodelBuilder.Entity<User>().Property(u => u.IsActive).HasDefaultValue(true);\nmodelBuilder.Entity<UserSecrets>().Property(s => s.IsActive).HasDefaultValue(false); // shared column\n\n// after\nmodelBuilder.Entity<User>().Property(u => u.IsActive).HasDefaultValue(true);\nmodelBuilder.Entity<UserSecrets>().Property(s => s.IsActive).HasDefaultValue(true);","handlingStrategy":"validation","validationCode":"foreach (var (col, props) in sharedColumnGroups)\n{\n    var resolved = props.Select(p => p.TryGetDefaultValue(storeObject, out var v) ? v : null).ToList();\n    if (resolved.Any(r => r is not null) && resolved.Distinct().Count() > 1)\n        Console.WriteLine($\"Column {col} has conflicting default values\");\n}","typeGuard":null,"tryCatchPattern":"try { _ = db.Model; } catch (InvalidOperationException ex) when (ex.Message.Contains(\"different default values\") && ex.Message.Contains(\"NULL\") == false) { // align HasDefaultValue on both properties }","preventionTips":["Set the default value on one entity and reuse the same value on its table-splitting partners.","Avoid mixing HasDefaultValue with implicit CLR defaults across a shared column.","Smoke-test the model at startup."],"tags":["model-validation","column-mapping","default-value","relational"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}