StevieB StevieB - 6 months ago 197
SQL Question

Entity Framework calling stored procedure expects parameter which was not supplied

I am calling my SP via Entity Framework like this :

NextSuperGroup supergroup = entities.Database.SqlQuery<NextSuperGroup>(
"super_group @user, @orderbyUnique",
new SqlParameter("@user", userName),
new SqlParameter("@orderbyUnique", true)).First();


And getting the error


Procedure or function 'super_group' expects parameter '@orderbyUnique', which was not supplied.


As you can see above I am supplying it.

Here's the stored procedure:

ALTER PROCEDURE [dbo].[super_group]
@user nvarchar(30)
,@stepLockDelay varchar(10) = '00:00:00'
,@orderbyUnique bit
AS


Any ideas why I am getting this error ?

JLe JLe
Answer

It probably should complain about the @user parameter as well if this is the case, but anyway - try to supply the parameter without the @ prefix:

NextSuperGroup supergroup = entities.Database.SqlQuery<NextSuperGroup>(
    "super_group @user, @orderbyUnique",
    new SqlParameter("user", userName),
    new SqlParameter("orderbyUnique", true)
).First();