This is my first attempt at using EF to call a SQL Server stored procedure passing in parameters. This is an update stored procedure that I'm testing, and I keep getting an error
Procedure or function 'Employee_Update' expects parameter '@EmployeeId', which was not supplied
If I put a breakpoint in the code where it's calling the stored procedure, I can see the parameters and that they are populated properly. I've also copied and pasted the parameter names between the stored procedure and my code to make sure I didn't misspell something.
Everything I've read about and see in the code suggests that it should work. I've also confirmed the stored procedure code is good by executing the stored procedure directly from SQL Server Management Studio, it works just fine.
Anyone have a suggestion on what I can try or see something that looks like it wouldn’t work?
List<SqlParameter> sqlParms = new List<SqlParameter>
{
new SqlParameter { ParameterName = "@EmployeeId", Value = employee.EmployeeID },
new SqlParameter { ParameterName = "@FirstName ", Value = employee.FirstName },
new SqlParameter { ParameterName = "@LastName", Value = employee.LastName},
new SqlParameter { ParameterName = "@MiddleInitial", Value = employee.MiddleName }
};
db.Database.ExecuteSqlRaw("EXEC dbo.Employee_Update", sqlParms.ToArray());
Update
Stored Proc Parameters
ALTER PROCEDURE [dbo].[Employee_Update]
(
@EmployeeId varchar(8),
@FirstName varchar(40),
@LastName varchar(40),
@MiddleInitial char(1)
)
