{"record":{"id":"3d016b27cca6ea26","repo":"dotnet/efcore","slug":"the-dbfunction-function-does-not-have-a-parame","errorCode":null,"errorMessage":"The DbFunction '{function}' does not have a parameter named '{parameter}'.","messagePattern":"The DbFunction '(.+?)' does not have a parameter named '(.+?)'\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Metadata/Internal/InternalDbFunctionBuilder.cs","lineNumber":235,"sourceCode":"    /// </summary>\n    public virtual bool CanSetTranslation(\n        Func<IReadOnlyList<SqlExpression>, SqlExpression>? translation,\n        ConfigurationSource configurationSource)\n        => (Metadata is { IsScalar: true, IsAggregate: false } || configurationSource == ConfigurationSource.Explicit)\n            && (configurationSource.Overrides(Metadata.GetTranslationConfigurationSource())\n                || Metadata.Translation == translation);\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 InternalDbFunctionParameterBuilder HasParameter(string name, ConfigurationSource configurationSource)\n    {\n        var parameter = Metadata.FindParameter(name);\n        return parameter == null\n            ? throw new ArgumentException(\n                RelationalStrings.DbFunctionInvalidParameterName(Metadata.MethodInfo?.DisplayName(), name))\n            : parameter.Builder;\n    }\n\n    IConventionDbFunction IConventionDbFunctionBuilder.Metadata\n    {\n        [DebuggerStepThrough]\n        get => Metadata;\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    [DebuggerStepThrough]\n    IConventionDbFunctionBuilder? IConventionDbFunctionBuilder.HasAnnotation(string name, object? value, bool fromDataAnnotation)","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Metadata/Internal/InternalDbFunctionBuilder.cs#L217-L253","documentation":"HasParameter(name) on a DbFunction builder returns the parameter builder only if a parameter with that exact name exists. The method throws an ArgumentException when Metadata.FindParameter(name) returns null — i.e. the declared method has no parameter with that name (typo, renamed parameter, or wrong overload).","triggerScenarios":"Calling .HasParameter(\"searchTerm\") when the underlying method's parameter is named \"term\"; using the parameter name from a different overload; refactor that renamed a method parameter without updating the DbFunction configuration.","commonSituations":"Renaming a method parameter via IDE refactor that does not touch OnModelCreating; copy-pasted configuration referencing another function's parameters; signature mismatch after a refactor.","solutions":["Open the method registered as the DbFunction and copy the exact parameter name (case-sensitive).","Update the .HasParameter(...) call to match the current parameter name.","If the parameter was intentionally removed, drop the HasParameter configuration block for it."],"exampleFix":"// before\npublic IQueryable<Order> Search(string term) => throw new NotSupportedException();\nmodelBuilder.HasDbFunction(typeof(AppDb).GetMethod(nameof(Search)))\n    .HasParameter(\"searchTerm\"); // wrong name\n\n// after\nmodelBuilder.HasDbFunction(typeof(AppDb).GetMethod(nameof(Search)))\n    .HasParameter(\"term\");","handlingStrategy":"validation","validationCode":"var fnBuilder = modelBuilder.HasDbFunction(typeof(AppDb).GetMethod(nameof(AppDb.Search))!);\nconst string paramName = \"term\";\nif (fnBuilder.Metadata.FindParameter(paramName) is null)\n{\n    throw new InvalidOperationException($\"DbFunction has no parameter '{paramName}'.\");\n}\nfnBuilder.HasParameter(paramName);","typeGuard":"static bool DbFunctionHasParameter(IReadOnlyDbFunction fn, string name)\n    => fn.FindParameter(name) is not null;","tryCatchPattern":null,"preventionTips":["Use nameof() on the method's parameter where possible so renames stay in sync.","After refactoring a method's parameters, grep for HasParameter calls referencing it."],"tags":["relational","dbfunctions","parameters","model-building"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}