{"record":{"id":"2f94262d4e34b1bb","repo":"dotnet/efcore","slug":"entitytype1-property1-and-entitytype2-pr-2f9426","errorCode":null,"errorMessage":"'{entityType1}.{property1}' and '{entityType2}.{property2}' are both mapped to column '{columnName}' in '{table}', but are configured with different scales ('{scale1}' and '{scale2}').","messagePattern":"'(.+?)\\.(.+?)' and '(.+?)\\.(.+?)' are both mapped to column '(.+?)' in '(.+?)', but are configured with different scales \\('(.+?)' and '(.+?)'\\)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs","lineNumber":1606,"sourceCode":"        if (currentPrecision != previousPrecision)\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.DuplicateColumnNamePrecisionMismatch(\n                    duplicateProperty.DeclaringType.DisplayName(),\n                    duplicateProperty.Name,\n                    property.DeclaringType.DisplayName(),\n                    property.Name,\n                    columnName,\n                    storeObject.DisplayName(),\n                    currentPrecision,\n                    previousPrecision));\n        }\n\n        var currentScale = property.GetScale(storeObject);\n        var previousScale = duplicateProperty.GetScale(storeObject);\n        if (currentScale != previousScale)\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.DuplicateColumnNameScaleMismatch(\n                    duplicateProperty.DeclaringType.DisplayName(),\n                    duplicateProperty.Name,\n                    property.DeclaringType.DisplayName(),\n                    property.Name,\n                    columnName,\n                    storeObject.DisplayName(),\n                    currentScale,\n                    previousScale));\n        }\n\n        if (property.IsConcurrencyToken != duplicateProperty.IsConcurrencyToken)\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.DuplicateColumnNameConcurrencyTokenMismatch(\n                    duplicateProperty.DeclaringType.DisplayName(),\n                    duplicateProperty.Name,\n                    property.DeclaringType.DisplayName(),","sourceCodeStart":1588,"sourceCodeEnd":1624,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L1588-L1624","documentation":"Two properties sharing a column declare different numeric scales (the second HasPrecision argument, or HasScale). Scale is the number of digits after the decimal point; differing scales on one physical column are irreconcilable, so EF rejects the model.","triggerScenarios":"ValidateCompatible() compares property.GetScale(storeObject) vs duplicateProperty.GetScale(storeObject) for a duplicate column and they differ.","commonSituations":"A rate column shared between owner and owned entity where one was configured for 4 decimal places and the other for 2; currency vs percentage fields that ended up mapped to the same column after refactoring.","solutions":["Set the same scale (second HasPrecision argument, or HasScale) on both properties.","Choose the larger scale to preserve precision across both usages.","Remap one property to a distinct column if the scales are genuinely different."],"exampleFix":"// before\nmodelBuilder.Entity<Order>().Property(o => o.Total).HasPrecision(18, 2);\nmodelBuilder.Entity<OrderDiscount>().Property(d => d.Total).HasPrecision(18, 4); // shared column\n\n// after\nmodelBuilder.Entity<Order>().Property(o => o.Total).HasPrecision(18, 4);\nmodelBuilder.Entity<OrderDiscount>().Property(d => d.Total).HasPrecision(18, 4);","handlingStrategy":"validation","validationCode":"foreach (var (col, props) in sharedColumnGroups)\n{\n    var scales = props.Select(p => p.GetScale(storeObject)).Distinct().ToList();\n    if (scales.Count > 1)\n        Console.WriteLine($\"Column {col} has conflicting scales: {string.Join(\", \", scales)}\");\n}","typeGuard":null,"tryCatchPattern":"try { _ = db.Model; } catch (InvalidOperationException ex) when (ex.Message.Contains(\"different scales\")) { // align the scale argument of HasPrecision on both properties }","preventionTips":["Always set precision and scale together via HasPrecision(p, s) and reuse the same call.","Use named constants for currency vs percentage scales.","Smoke-test the model at startup."],"tags":["model-validation","column-mapping","scale","decimal","relational"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}