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