无法从存储过程生成EF模型 [英] Can't generate EF model from stored procedure
问题描述
我正在现有数据库之上构建一个简单的Web应用程序,无法让Entity Framework正常运行。 Visual Studio 2013,EF6。
我在数据库中创建了一个存储过程,它接受两个参数(使用默认值)并返回一个结果集。我的目标是为两个参数(日期和短字符串)提供用户输入,然后将请求提交给服务器(WebAPI),
返回格式化为JSON的结果集,然后呈现表客户端通过Knockout(最终,客户端缓存,排序和过滤将发挥作用)。
我创建了项目,并尝试添加数据模型从数据库中选择我的存储过程,遵循本教程:www.entityframeworktutorial.net/stored-procedure-in-entity-framework.aspx(我无法链接它,因为我没有验证)。
I'm building a simple web application on top of an existing database and cannot get Entity Framework working properly with it. Visual Studio 2013, EF6.
I've created a stored procedure in the database which takes two parameters (with default values) and returns a single resultset. My goal is to have user input for the two parameters (a date and a short string), then submit the request to the server (WebAPI),
return the resultset formatted as JSON, and then render the table client-side via Knockout (eventually, client-side caching, sorting & filtering will come into play).
I've created the project, and attempted to add the data model from the database, selecting only my stored procedure, following this tutorial: www.entityframeworktutorial.net/stored-procedure-in-entity-framework.aspx (I can't link it as I'm not verified).
然而,当它完成时,我没有在模型资源管理器中看到教程说我应该的所有内容;没有生成复杂类型。如果我尝试编辑相应的函数导入并单击列信息,我会得到"所选的存储过程
或函数不返回任何列。"这使我处于上面链接的页面的中点,而不知道下一步该去哪里。如果我在SSMS中执行存储过程或通过PowerShell中的Invoke-SqlCmd执行存储过程,我会得到预期的结果,所以我知道
的过程有效,我有权执行它。
我在Visual Studio中做错了什么或者错误地创建了我的存储过程?我真的不知道从哪里开始。
However, when it finishes, I don't see everything in the Model Explorer that the tutorial says I should; no Complex Type is generated. If I attempt to edit the corresponding Function Import and click Column Information, I get "The selected stored procedure
or function returns no columns." This leaves me at the midpoint of the page I linked above and not knowing where to go next. If I execute the stored procedure in SSMS or via Invoke-SqlCmd in PowerShell, I get the expected results, so I know the procedure
works and I have rights to execute it.
Have I done something wrong in Visual Studio or created my stored procedure incorrectly? I really don't know where to go from here.
推荐答案
AlevyInRoc,
Hi AlevyInRoc,
感谢您在MSDN论坛上发帖。
Thank you for posting in MSDN forum.
因为它与
ADO.NET实体框架 ,
我们将此案例移至 ADO.NET
实体框架和LINQ to Entities
论坛,你将获得
ADO.NET实体框架 专家。
最好的问候,
这篇关于无法从存储过程生成EF模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!