title: Getting a result feedback from a stored procedure in Entity Framework
body: <p>In a SQL Server 2008 I have a simple stored procedure moving a bunch of records to another table:</p>
  
  <pre><code>CREATE PROCEDURE [dbo].MyProc(@ParamRecDateTime [datetime])
  AS
  BEGIN
  SET NOCOUNT ON;
  
  INSERT INTO [dbo].Table2 
  SELECT 
  ...,
      ...
  FROM [dbo].Table1 
        WHERE RecDateTime &lt;= @ParamRecDateTime    
  
  DELETE FROM [dbo].Table1 
        WHERE RecDateTime &lt;= @ParamRecDateTime        
  END
  </code></pre>
  
  <p>Running it from within SQL Server Management Studio, I get the job done and return value = 0</p>
  
  <pre><code> DECLARE @return_value int
   EXEC    @return_value = dbo.MyProc @ParamRecDateTime = '2011-06-25 11:00:00.000'
   SELECT  'Return Value' = @return_value
  </code></pre>
  
  <p>But when I call the same stored procedure from an app using Entity framework, I also get the job done but the return value is "-1":</p>
  
  <pre><code>int result = myrepository.MyProc(datetimePar);
  MessageBox.Show(result.ToString());
  </code></pre>
  
  <p>I didn't manage to find an explanation for this error, but found <a href="https://stackoverflow.com/questions/1035789/return-value-from-a-stored-proc-on-error">this</a> discouraging post, where it's said that there is no standard for this type of return codes in SQL Server.</p>
  
  <p><strong>What is the good, reliable way of getting know of a Stored Procedure execution result when calling it from Entity Framework and when the Stored Procedure doesn't return any entities?</strong></p>