更新时间:2022-10-14 22:43:29
OK - 这是一步一步的方式:
(1)add你的存储过程到EDMX文件(当你冷杉(2)使用从数据库更新模型
并选择存储过程)
(2)一旦您在模型中存储过程,请使用模型浏览器
添加函数导入
:
(4)一旦你这样做 - 您现在应该在模型浏览器的概念模型部分中看到存储过程,以及新生成的复杂类型ld也出现在这里:
I am trying to use a stored procedure in Entity Framework that returns nothing.
I did the following:
Added a function (right click on stored procedure -> add -> function import-> Complex Type -> Get column information -> create New Complex-Type)
My function name: summarySP_Result
. After building the project the entity class is not generated in Generated_code
(BusinessAccount.web.g.cs
)
But entity classes for tables and views are all created but nor for stored procedure.
Can anybody give the idea why it is not generated entity class in BusinessAccount.web.g.cs
?
Update :
Let me confirm ReturnDataFromTemTable_result
entity class created in your XXXXXX.web.g.cs
class.
Like :
[DataContract(Namespace="http://schemas.datacontract.org/2004/07/BizFramework.Web.Model")]
public sealed partial class ReturnDataFromTemTable_Result : Entity
{
-------------------
}
OK - here's the step-by-step way of doing this:
(1) add your stored procedure to the EDMX file (when you first create it, or later on by using Update model from database
and picking that stored procedure)
(2) once you have the stored procedure in your model - use the Model Browser
to add a Function Import
:
(3) the next dialog that pops up is vitally important - you need to (1) define that the stored procedure returns a collection of complex types, then you need to (2) get the column info from that stored procedure to know what columns it will return, then (3) you tell Visual Studio to generate a new complex type based on that column info:
(4) once you've done that - you should now see the stored procedure in your conceptual model section in the Model Browser, and the newly generated complex type should show up there, too: