{"record":{"id":"180d39cdf45df585","repo":"dotnet/efcore","slug":"the-property-entitytype-property-is-mapped-t-180d39","errorCode":null,"errorMessage":"The property '{entityType}.{property}' is mapped to an output parameter of the stored procedure '{sproc}', but it is also mapped to an output original value output parameter. A store-generated property can only be mapped to one output parameter.","messagePattern":"The property '(.+?)\\.(.+?)' is mapped to an output parameter of the stored procedure '(.+?)', but it is also mapped to an output original value output parameter\\. A store-generated property can only be mapped to one output parameter\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs","lineNumber":803,"sourceCode":"            }\n\n            if (parameter.PropertyName == null)\n            {\n                continue;\n            }\n\n            switch (storeObjectIdentifier.StoreObjectType)\n            {\n                case StoreObjectType.InsertStoredProcedure:\n                case StoreObjectType.UpdateStoredProcedure:\n                    if (parameter.Direction != ParameterDirection.Input\n                        && !storeGeneratedProperties.Remove(property!.Name))\n                    {\n                        if (sproc.Parameters.Any(p => p.PropertyName == property.Name\n                                && p.ForOriginalValue != parameter.ForOriginalValue\n                                && p.Direction != ParameterDirection.Input))\n                        {\n                            throw new InvalidOperationException(\n                                RelationalStrings.StoredProcedureOutputParameterConflict(\n                                    entityType.DisplayName(), parameter.PropertyName, storeObjectIdentifier.DisplayName()));\n                        }\n\n                        throw new InvalidOperationException(\n                            RelationalStrings.StoredProcedureOutputParameterNotGenerated(\n                                entityType.DisplayName(), parameter.PropertyName, storeObjectIdentifier.DisplayName()));\n                    }\n\n                    break;\n                case StoreObjectType.DeleteStoredProcedure:\n                    if (!property!.IsPrimaryKey()\n                        && !property.IsConcurrencyToken)\n                    {\n                        throw new InvalidOperationException(\n                            RelationalStrings.StoredProcedureDeleteNonKeyProperty(\n                                entityType.DisplayName(), parameter.PropertyName, storeObjectIdentifier.DisplayName()));\n                    }","sourceCodeStart":785,"sourceCodeEnd":821,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L785-L821","documentation":"Thrown when a single store-generated property is mapped to TWO different non-input parameters of an insert/update sproc — one a normal output parameter and one an output-original-value parameter (ForOriginalValue differs). The validator first tries to remove the property from the storeGeneratedProperties set; if it was already consumed by an earlier output parameter, it scans sproc.Parameters for any other parameter with the same property name, different ForOriginalValue flag, and non-Input direction, and reports the conflict. Store-generated values may only flow back through one channel.","triggerScenarios":"On an Insert/UpdateUsingStoredProcedure, calling both .HasOutputParameter(p => p.Id) and .HasOutputParameter(p => p.Id, forOriginalValue: true) (or two parameters with the same PropertyName but different ForOriginalValue). Mixing a result column for the same property with an output parameter also trips related checks.","commonSituations":"Wanting EF to capture both current value and original value of a store-generated column; accidentally registering the same property twice via fluent calls in different locations; refactor that moved an output parameter without removing the old mapping.","solutions":["Keep only one output mapping for the store-generated property: prefer HasOutputParameter(p => p.Foo) and delete the duplicate HasOutputParameter(... forOriginalValue: true) for the same property.","If you genuinely need the original value too, that property is not store-generated in the sense EF needs — reconfigure it as a regular concurrency token with HasOriginalValueParameter, not an output parameter.","Inspect every parameter on the sproc mapping whose PropertyName equals the offending one and remove all but one with Direction != Input."],"exampleFix":"// before\nentityType.InsertUsingStoredProcedure(\"InsertOrder\",\n    sp =>\n    {\n        sp.HasResultColumn(o => o.OrderId);\n        sp.HasOutputParameter(o => o.OrderId); // conflict: two outputs for OrderId\n    });\n\n// after\nentityType.InsertUsingStoredProcedure(\"InsertOrder\",\n    sp =>\n    {\n        sp.HasResultColumn(o => o.OrderId);\n    });","handlingStrategy":"validation","validationCode":"// Ensure each store-generated property has at most one non-input parameter mapping.\nforeach (var et in model.GetEntityTypes())\n{\n    foreach (var sproc in new[] { et.GetInsertStoredProcedure(), et.GetUpdateStoredProcedure() })\n    {\n        if (sproc == null) continue;\n        var outputsByProp = sproc.Parameters\n            .Where(p => p.Direction != System.Data.ParameterDirection.Input && p.PropertyName != null)\n            .GroupBy(p => p.PropertyName);\n        foreach (var g in outputsByProp.Where(g => g.Select(p => p.ForOriginalValue).Distinct().Count() > 1))\n            Console.WriteLine($\"Property {g.Key} on {sproc.Name} has conflicting output mappings.\");\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep all sproc read-back config in one fluent block per entity so duplicates are visually obvious.","Prefer result columns over output parameters when the sproc returns a result set.","Code-review sproc mappings whenever an entity gains a new store-generated property."],"tags":["ef-core","stored-procedures","model-validation","store-generated"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}