从EntityFramework调用存储过程时出错

从EntityFramework调用存储过程时出错

本文介绍了从EntityFramework调用存储过程时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我已按照以下步骤操作:



我正在尝试从EntityFramework访问商店程序。首先我在Azure数据库中创建了存储过程:





然后,我从数据库更新了.edmx模型,只选择了我想要的StoredProcedure。





一旦完成,在功能导入我看到StoredProcedure添加,但不是在StoredProcedures部分。
我可以做什么,以便它出现在这里?





在功能导入部分中,所有参数均设置为输入,MaxReference应标记为输出。
如何更改?





尽管这两个问题我已经执行了代码:





我得到以下例外:

  EntityCommandCompilationException 
准备命令定义时发生错误。查看内部例外情况。

和InnerException:

 函数import'DataModelEntities.AssignMaxSalesRef'无法执行,因为它没有分配给存储功能。 
解决方案

你可能想参考这篇博文:,它讨论一个类似的问题。原因显然是:

通过以下分步解决方案:

另一种类似的疑难解答资源关于更新edmx文件的分步说明(和图像!):。


I am trying to access a Store Procedure from EntityFramework.

I have followed these steps:

First of all I have created the Stored Procedure in the Azure Database:

Then, I have updated the .edmx model from database, selecting only the StoredProcedure I want.

Once done, in the Function Import I see the StoredProcedure added, but not in the section of StoredProcedures.What can I do so that it appears here?

In the Function Import section, all the parameters are set as Input, whereas "MaxReference" should be marked as Output.How can I change it?

Although these two issues I have executed the code:

and I got the following exception:

EntityCommandCompilationException
An error occurred while preparing command definition. See the inner exception for details.

and the InnerException:

The function import 'DataModelEntities.AssignMaxSalesRef' cannot be executed because it is not assigned to a storage function.
解决方案

You may want to refer to this blog post: FunctionImport is not mapped to a store function Error, that discusses a similar problem. The cause apparently being:

With the following step-by-step solution:

Another troubleshooting resource with similar step-by-step instructions (and images!) on updating the edmx file: The function import cannot be executed because it is not mapped to a store function.

这篇关于从EntityFramework调用存储过程时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 23:21