title: Entity Framework Core 3.1 Return value (int) from stored procedure
body: <p>this returns -1, how can i get the actual return value from stored procedure?</p>
  
  <p>here is my stored procedure</p>
  
  <pre><code>ALTER PROCEDURE [Production].[Select_TicketQuantity]
      @Ticket NVARCHAR(25),
      @Reference NVARCHAR(20)
  AS
  BEGIN
  
      declare @SQL nvarchar (4000)
      SET @SQL = 'select QARTCOL as Quantidade from D805DATPOR.GCARCCR1 where NCOLGIA = ' + @Ticket + ' AND NARTCOM = ''' + @Reference + ''''
      SET @SQL = N'select CONVERT(int,Quantidade) as Quantidade from OpenQuery(MACPAC, ''' + REPLACE(@SQL, '''', '''''') + ''')'
      PRINT @SQL
      EXEC (@SQL)
  
  END   
  </code></pre>
  
  <p>C# code</p>
  
  <pre><code>int? quantity= 0;
  try
  {
      quantity= await _context.Database.ExecuteSqlRawAsync("EXEC Production.Select_TicketQuantity @p0, @p1", parameters: new[] { ticket, reference});
  }
  catch (Exception ex)
  {
      _logger.LogError($"{ex}");
      return RedirectToPage("Index");
  }
  </code></pre>