title: EF ExecuteStoredCommand with ReturnValue parameter
body: <p>I'm creating a new application which needs to interface with legacy code :(.</p>
  
  <p>The stored procedure I'm attempting to call uses RETURN for its result. My attempts to execute and consume the return value result in the exception:</p>
  
  <blockquote>
    <p>InvalidOperationException: When executing a command, parameters must be exclusively database parameters or values.</p>
  </blockquote>
  
  <p>Changing the stored proc to return the value another way isn't desired, since it either requires updating the legacy app or maintaining a nearly duplicate stored proc.</p>
  
  <p>The legacy stored proc synopsis:</p>
  
  <pre><code>DECLARE @MyID INT
  INSERT INTO MyTable ...
  SELECT @MyID = IDENTITY()
  RETURN @MyID
  </code></pre>
  
  <p>My Entity Framework / DbContext work, which yields the above InvalidOperationException.</p>
  
  <pre><code> SqlParameter parm = new SqlParameter() {
      ParameterName = "@MyID",
      Direction = System.Data.ParameterDirection.ReturnValue
   };
  
   DbContext.Database.ExecuteSqlCommand("EXEC dbo.MyProc", parm);
  </code></pre>
  
  <p>Looking for any and all solutions which don't require the stored proc to be modified.</p>