'How does Entity Framework creates a return model from a stored procedure?
I would like to understand how does EF creates a return model from a stored procedure. I know how to get the return model and even how to customize it but I couldn't find any documentation or explanation on how does EF really get the Return Model from a complicated SP. I mean, Does it need to actually run the SP when creating the model? (I guess not, How would it know what parameters to use). Is there any metadata in a system table that contain the return type? Does it use the execution plan somehow?
Any insight would be appreciated.
Solution 1:[1]
In order to get the type returned from the Stored Procedure, EntityFramework runs the SP.
Well, if there is an error in running the SP, then EF fails to get the returned type, and then EF determines the type int. It is not always easy to understand what is wrong with the SP.
Well, I found a way to understand that. This is done by running the "SQL Server Profiler" tool, where you can trace the SP as how EF ran it, and so you can understand what the error is.
By the way, it is very interesting to follow the SP that EF runs. You can learn a lot from this !.
If you are unfamiliar with the SQL Server Profiler tool, you can read about it here. And here you can see an example of how to use it: How to trace with SQL Server profiler
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Haim Tabak |