{"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/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L1697-L1733","documentation":"Two properties mapped to the same column have DefaultValue facets that, after value-converter normalization, produce different default values. The physical column can have only one DEFAULT, so model finalization aborts. Thrown from ValidateCompatible (the TryGetDefaultValue/GetDefaultColumnValue branch).","triggerScenarios":"Sibling TPH types where one calls HasDefaultValue(1) and the other HasDefaultValue(0) on a same-named property; an owned entity and owner setting different default values; table splitting with conflicting defaults; one side using a value converter that changes the converted default.","commonSituations":"Changing a Status default from 0 to 1 on one entity only; refactoring a value converter so the converted default no longer matches the sibling; introducing a default for a new property that collides with an existing column's default.","solutions":["Set HasDefaultValue to the same value on both properties (after value-converter normalization).","If different defaults are needed, rename one column with HasColumnName.","Drop the explicit default from one side and let it match the other."],"exampleFix":"// before\nmodelBuilder.Entity<Student>().Property(s => s.Status).HasDefaultValue(0);\nmodelBuilder.Entity<Teacher>().Property(t => t.Status).HasDefaultValue(1);\n// after\nconst int DefaultStatus = 0;\nmodelBuilder.Entity<Student>().Property(s => s.Status).HasDefaultValue(DefaultStatus);\nmodelBuilder.Entity<Teacher>().Property(t => t.Status).HasDefaultValue(DefaultStatus);","handlingStrategy":"validation","validationCode":"using (var ctx = new MyContext()) { ctx.Model.ToDebugString(); }\nctx.Model.FindEntityType(typeof(Student))!.FindProperty(\"Status\")!.TryGetDefaultValue(out var a);\nctx.Model.FindEntityType(typeof(Teacher))!.FindProperty(\"Status\")!.TryGetDefaultValue(out var b);\nDebug.Assert(Equals(a, b), $\"DefaultValue mismatch: {a} vs {b}\");","typeGuard":null,"tryCatchPattern":"try { using var ctx = new MyContext(); _ = ctx.Model; }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"different default values\"))\n{ log.Error(\"Default value mismatch on shared column: {Msg}\", ex.Message); throw; }","preventionTips":["Define HasDefaultValue once via a shared configuration for shared columns.","Account for value-converter normalization when comparing defaults across siblings.","Add a startup model-build test."],"tags":["ef-core","model-validation","default-value","shared-table","column-mapping"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}