{"record":{"id":"a3bcd6ddce8868de","repo":"dotnet/efcore","slug":"entitytype1-property1-and-entitytype2-pr-a3bcd6","errorCode":null,"errorMessage":"'{entityType1}.{property1}' and '{entityType2}.{property2}' are both mapped to column '{columnName}' in '{table}', but are configured with different precisions ('{precision1}' and '{precision2}').","messagePattern":"'(.+?)\\.(.+?)' and '(.+?)\\.(.+?)' are both mapped to column '(.+?)' in '(.+?)', but are configured with different precisions \\('(.+?)' and '(.+?)'\\)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs","lineNumber":1590,"sourceCode":"        }\n\n        if (property.IsFixedLength(storeObject) != duplicateProperty.IsFixedLength(storeObject))\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.DuplicateColumnNameFixedLengthMismatch(\n                    duplicateProperty.DeclaringType.DisplayName(),\n                    duplicateProperty.Name,\n                    property.DeclaringType.DisplayName(),\n                    property.Name,\n                    columnName,\n                    storeObject.DisplayName()));\n        }\n\n        var currentPrecision = property.GetPrecision(storeObject);\n        var previousPrecision = duplicateProperty.GetPrecision(storeObject);\n        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(),","sourceCodeStart":1572,"sourceCodeEnd":1608,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L1572-L1608","documentation":"Two properties mapped to the same column declare different numeric precisions via HasPrecision(precision, scale). Precision is the total digit count of a decimal/numeric column; because the column is shared, EF cannot reconcile two different precisions and throws rather than silently widening or narrowing one side.","triggerScenarios":"ValidateCompatible() reads property.GetPrecision(storeObject) and duplicateProperty.GetPrecision(storeObject) and they differ. Happens when two entities sharing a column each call HasPrecision with different first arguments.","commonSituations":"Money/rate fields shared between an owned detail and its owner, each set to different precisions; scaffold then manual decimal tweaks that touched only one entity; domain refactor splitting an entity but leaving inconsistent precision.","solutions":["Call HasPrecision(p, s) on both properties with identical precision.","Pick the broader precision and apply it to both sides to avoid silent truncation.","Remap one property to its own column if different precision is genuinely needed."],"exampleFix":"// before\nmodelBuilder.Entity<Invoice>().Property(i => i.Amount).HasPrecision(18, 2);\nmodelBuilder.Entity<InvoiceTax>().Property(t => t.Amount).HasPrecision(12, 2); // shared column\n\n// after\nmodelBuilder.Entity<Invoice>().Property(i => i.Amount).HasPrecision(18, 2);\nmodelBuilder.Entity<InvoiceTax>().Property(t => t.Amount).HasPrecision(18, 2);","handlingStrategy":"validation","validationCode":"foreach (var (col, props) in sharedColumnGroups)\n{\n    var precisions = props.Select(p => p.GetPrecision(storeObject)).Distinct().ToList();\n    if (precisions.Count > 1)\n        Console.WriteLine($\"Column {col} has conflicting precisions: {string.Join(\", \", precisions)}\");\n}","typeGuard":null,"tryCatchPattern":"try { _ = db.Model; } catch (InvalidOperationException ex) when (ex.Message.Contains(\"different precisions\")) { // align HasPrecision on both properties }","preventionTips":["Define money/decimal facets (precision, scale) as constants and reuse them.","Review decimal configuration when splitting a table or merging entities.","Smoke-test the model at startup."],"tags":["model-validation","column-mapping","precision","decimal","relational"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}