Capturing Output Arguments from Stored Procedures in SQL Server with Entity Framework Core

Pamphylios 21 Reputation points
2022-07-13T12:44:18.053+00:00

Dear Friends,

I would appreciate an explanation of how to capture the values of output parameters when calling stored procedures in SQL Server 2019 from Entity Framework Core 6.

Thank you for your trouble, and best regards,

Eric Weinberger

Developer technologies | .NET | Entity Framework Core
Developer technologies | Transact-SQL
Developer technologies | Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
SQL Server | Other
0 comments No comments
{count} votes

Answer accepted by question author
  1. YufeiShao-msft 7,151 Reputation points
    2022-07-14T02:47:06.35+00:00

    Hi @Pamphylios

    About FromSqlRaw(), FromSqlInterpolated(), you can see:

    Working with Stored Procedure in Entity Framework Core

    EF core provides:
    DbSet<TEntity>.FromSql()
    DbContext.Database.ExecuteSqlCommand()

    How to use a SQL output parameter with FromSqlInterpolated? Or alternative

    and

    How to call stored procedures with OUTPUT parameters with FromSqlRaw in EF Core

    -------------

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Olaf Helper 47,586 Reputation points
    2022-07-13T13:15:15.553+00:00
    0 comments No comments

  2. Pamphylios 21 Reputation points
    2022-07-13T16:43:51.037+00:00

    Thank you, @Olaf Helper .
    It looks as though this solution would work in ADO.NET.
    I should have been more specific, but I am looking for a way to capture output arguments from stored procedures using FromSqlRaw(), FromSqlInterpolated(), or something similar.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.