{"record":{"id":"f7f626b81999545b","repo":"dotnet/efcore","slug":"original-value-parameter-parameter-is-not-allo","errorCode":null,"errorMessage":"Original value parameter '{parameter}' is not allowed on insert stored procedure '{sproc}'. Use HasParameter() instead.","messagePattern":"Original value parameter '(.+?)' is not allowed on insert stored procedure '(.+?)'\\. Use HasParameter\\(\\) instead\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs","lineNumber":716,"sourceCode":"        var originalValueProperties = new Dictionary<string, IProperty>(properties);\n        var parameterNames = new HashSet<string>();\n        foreach (var parameter in sproc.Parameters)\n        {\n            IProperty? property = null;\n            if (parameter.PropertyName != null)\n            {\n                if (parameter.ForOriginalValue == true)\n                {\n                    if (!originalValueProperties.TryGetAndRemove(parameter.PropertyName, out property))\n                    {\n                        throw new InvalidOperationException(\n                            RelationalStrings.StoredProcedureParameterNotFound(\n                                parameter.PropertyName, entityType.DisplayName(), storeObjectIdentifier.DisplayName()));\n                    }\n\n                    if (storeObjectIdentifier.StoreObjectType == StoreObjectType.InsertStoredProcedure)\n                    {\n                        throw new InvalidOperationException(\n                            RelationalStrings.StoredProcedureOriginalValueParameterOnInsert(\n                                parameter.Name, storeObjectIdentifier.DisplayName()));\n                    }\n                }\n                else\n                {\n                    if (!properties.TryGetAndRemove(parameter.PropertyName, out property))\n                    {\n                        throw new InvalidOperationException(\n                            RelationalStrings.StoredProcedureParameterNotFound(\n                                parameter.PropertyName, entityType.DisplayName(), storeObjectIdentifier.DisplayName()));\n                    }\n\n                    if (storeObjectIdentifier.StoreObjectType == StoreObjectType.DeleteStoredProcedure)\n                    {\n                        throw new InvalidOperationException(\n                            RelationalStrings.StoredProcedureCurrentValueParameterOnDelete(\n                                parameter.Name, storeObjectIdentifier.DisplayName()));","sourceCodeStart":698,"sourceCodeEnd":734,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L698-L734","documentation":"Thrown when an original-value parameter (HasOriginalValueParameter) is configured on an Insert stored procedure. Inserts only use current values; original values have no meaning before a row exists. The validator rejects ForOriginalValue==true parameters on insert sprocs and suggests HasParameter instead.","triggerScenarios":".InsertStoredProcedure().HasOriginalValueParameter(\"RowVersion\"); mixing concurrency-token-style original-value params onto an insert sproc.","commonSituations":"Copy-pasting update/delete sproc config (which may use original values) onto an insert sproc.","solutions":["Replace HasOriginalValueParameter with HasParameter on the insert sproc.","Remove the original-value parameter entirely if it is not needed for insert."],"exampleFix":"// before\n.InsertStoredProcedure(\"sp_InsertBlog\", sp =>\n{\n    sp.HasOriginalValueParameter(\"CreatedAt\");\n});\n\n// after\n.InsertStoredProcedure(\"sp_InsertBlog\", sp =>\n{\n    sp.HasParameter(\"CreatedAt\");\n});","handlingStrategy":"validation","validationCode":"foreach (var et in modelBuilder.Model.GetEntityTypes())\n{\n    var ins = et.GetInsertStoredProcedure();\n    if (ins != null && ins.Parameters.Any(p => p.ForOriginalValue == true))\n        throw new InvalidOperationException($\"{et.DisplayName()} insert sproc has original-value params\");\n}","typeGuard":null,"tryCatchPattern":"try { _ = ctx.Model; } catch (InvalidOperationException ex) when (ex.Message.Contains(\"not allowed on insert stored procedure\")) { /* replace HasOriginalValueParameter with HasParameter */ }","preventionTips":["On insert sprocs use HasParameter only; reserve HasOriginalValueParameter for update/delete."],"tags":["ef-core","stored-procedures","parameters","insert","original-value","model-validation"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}