{"record":{"id":"64881a9e28114ed7","repo":"dotnet/efcore","slug":"the-original-value-parameter-for-the-property-pr","errorCode":null,"errorMessage":"The original value parameter for the property '{property}' cannot be added to the stored procedure '{sproc}' because another original value parameter for this property already exists.","messagePattern":"The original value parameter for the property '(.+?)' cannot be added to the stored procedure '(.+?)' because another original value parameter for this property already exists\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Metadata/Internal/StoredProcedure.cs","lineNumber":544,"sourceCode":"    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to\n    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in\n    ///     any release. You should only use it directly in your code with extreme caution and knowing that\n    ///     doing so can result in application failures when updating to a new Entity Framework Core release.\n    /// </summary>\n    public virtual StoredProcedureParameter? FindOriginalValueParameter(string propertyName)\n        => _originalValueParameters.GetValueOrDefault(propertyName);\n\n    /// <summary>\n    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to\n    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in\n    ///     any release. You should only use it directly in your code with extreme caution and knowing that\n    ///     doing so can result in application failures when updating to a new Entity Framework Core release.\n    /// </summary>\n    public virtual StoredProcedureParameter AddOriginalValueParameter(string propertyName)\n    {\n        if (_originalValueParameters.ContainsKey(propertyName))\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.StoredProcedureDuplicateOriginalValueParameter(\n                    propertyName, ((IReadOnlyStoredProcedure)this).GetStoreIdentifier()?.DisplayName()));\n        }\n\n        var parameter = new StoredProcedureParameter(this, rowsAffected: false, propertyName, originalValue: true);\n        _parameters.Add(parameter);\n        _originalValueParameters.Add(propertyName, parameter);\n\n        return parameter;\n    }\n\n    /// <summary>\n    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to\n    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in\n    ///     any release. You should only use it directly in your code with extreme caution and knowing that\n    ///     doing so can result in application failures when updating to a new Entity Framework Core release.\n    /// </summary>\n    public virtual StoredProcedureParameter? FindRowsAffectedParameter()","sourceCodeStart":526,"sourceCodeEnd":562,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Metadata/Internal/StoredProcedure.cs#L526-L562","documentation":"Thrown when AddOriginalValueParameter(propertyName) is called for a property that already has an original-value parameter on the stored procedure mapping. A property may have at most one original-value parameter (used for optimistic concurrency updates).","triggerScenarios":"StoredProcedure.AddOriginalValueParameter(propertyName) when _originalValueParameters.ContainsKey(propertyName). Triggered by calling HasOriginalValueParameter(p => p.X) twice, or repeating an update mapping configuration that re-adds the same original-value parameter.","commonSituations":"Update stored procedure mappings built programmatically with duplicate calls; combining attribute and fluent configuration that both add the same original-value parameter; copy/paste errors.","solutions":["Check StoredProcedure.FindOriginalValueParameter(propertyName) before adding.","Remove the duplicate HasOriginalValueParameter call.","Build the update mapping once, declaratively.","Distinguish current-value vs original-value parameters if both are intended (they are separate channels and do not conflict with each other)."],"exampleFix":"// before\nupdateSproc.HasOriginalValueParameter(p => p.RowVersion);\nupdateSproc.HasOriginalValueParameter(p => p.RowVersion); // throws\n\n// after: declare once\nupdateSproc.HasOriginalValueParameter(p => p.RowVersion);","handlingStrategy":"validation","validationCode":"// Before adding an original-value parameter, check existence.\nif (sproc.FindOriginalValueParameter(propertyName) is null)\n    sproc.HasOriginalValueParameter(propertyName);\nelse\n    Console.WriteLine($\"Original-value parameter for '{propertyName}' already exists; skipping.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Configure update stored procedure mappings once, declaratively.","Distinguish current-value vs original-value parameters; they are independent channels and do not substitute for each other.","Use FindOriginalValueParameter before programmatic AddOriginalValueParameter calls."],"tags":["ef-core","relational-metadata","stored-procedure","parameter","duplicate","original-value"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}