I'm attempting to call a stored proc through EF and retrieve a return value from the stored proc. I've used this answer as a guide. Here is my stored proc:
CREATE PROCEDURE [dbo].[usp_test]
(
@result int OUT
)
AS
BEGIN
--DO STUFF
SET @result = 0
END
Here is how I'm calling it from EF:
var status = new SqlParameter
{
ParameterName = "result",
DbType = DbType.Int32,
Direction = ParameterDirection.Output
};
var result = context.Database.SqlQuery<int>("EXEC usp_test @result", status);
var wasSuccessful = result.First() == 1;
if (!wasSuccessful)
{
//DO STUFF
}
I'm getting this error message:
The data reader has more than one field. Multiple fields are not valid for EDM primitive or enumeration types
What am I doing wrong?