- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我正在尝试从 EntityFramework 访问存储过程。
我已按照以下步骤操作:
首先,我在 Azure 数据库中创建了存储过程:
然后,我从数据库更新了 .edmx 模型,仅选择我想要的 StoredProcedure。
完成后,在函数导入中我看到添加了 StoredProcedure,但在 StoredProcedures 部分中没有看到。我该怎么做才能让它出现在这里?
在“函数导入”部分中,所有参数均设置为“输入”,而“MaxReference”应标记为“输出”。我该如何更改它?
虽然这两个问题我已经执行了代码:
我得到了以下异常:
EntityCommandCompilationException
An error occurred while preparing command definition. See the inner exception for details.
和内部异常:
The function import 'DataModelEntities.AssignMaxSalesRef' cannot be executed because it is not assigned to a storage function.
最佳答案
您可能需要引用这篇博文:FunctionImport is not mapped to a store function Error ,讨论了类似的问题。原因显然是:
I had to make changes to a stored procedure and it got deleted from the Entity Data Model Xml file (*.edmx)
使用以下分步解决方案:
There is an easy solution to fix that error. First open your edmx file and right click on the model that owns the stored procedure. Click Add then select “Add Function Import”.
Add the same Function Import name that is used in your Context file (if like me, the method was already created but messed up, otherwise is all new and it will be recreared anyways). Select the Stored Procedure Name that you are trying to fix. Choose the Entities and click OK. A new window might pop up “Verify that the FunctionImport name is unique”.
If that is the case, and you get the “Verify that the FunctionImport name is unique” window popup, do the following: Open your *.edmx file and right click over the model you want to update. Select “Show in Model Browser”. Now the Model Browser window opens up. Go to: {myProject}.DataModel > EntityContainer: {somethingEntities} > Function Imports. The function import causing the problem should be there, just delete it and save the *.edmx file.
Try to add the Function Import again. Voila! no issues this time. Save the *.edmx file and recreate the context file (by making a simple non-invasive change like adding a space to the {myProject}.Context.tt file). make sure the new method:
public virtual ObjectResult<MyEntity> <MyEntity>_NameoftheSP(parametets)
is present in your Context file.
另一个故障排除资源,其中包含有关更新 edmx 文件的类似分步说明(和图像!):The function import cannot be executed because it is not mapped to a store function .
关于c# - 从 EntityFramework 调用存储过程时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30216830/
全部: 我们使用 ASP.NET Web 窗体开始了我们的项目。 我们的 ASP.NET C# web 应用程序在以下环境中使用 .NET Framework 4 ASP.NET Web Forms.
我在尝试为 Entity Framework Core 添加迁移到 Code First 项目时遇到错误,这里是详细信息... 我创建了一个新的 ASP.Net Core Web 项目(VS 2017
Error 1 Copying file bin\EntityFramework.SqlServer.xml to obj\Debug\Package\PackageTmp\bin\Entit
我有一个WPF应用程序,我使用了MVVM体系结构,数据库sql server compact 4。 首先是Entityframework.sqlserverCompact数据库,我使用了通用存储库模式
例如,将 products.Where(p => p.LastModifiedOn > someDate) 总是以相同的订单返回产品(无论如何订购,只要每次调用相同的代码时都是一致的)?或者我应该添加
好吧,假设我有一个用户表,然后是一个记录所有登录尝试的表(Id(计数器)、userId、时间以及是否成功) 现在在我的实体模型中,我希望它成为 2 个关联的一个,包含所有成功尝试的时间和一个包含所有不
我正在努力处理如何最好地跨多个 Visual Studio 项目分解域模型。我正在使用 EntityFramework 4 和企业类型模式来合理化一个可以重用于各种应用程序的系统。最终我想得到一组可以
是否可以使用 POCO 和 EF 处理以下情况?我想要一个 Vehicles 表,有一些 bool 字段,如 IsFast、IsVan、IsTruck,然后有一个 Vehicles 类,有一个 Fas
当我通过传递比较泛型类型 TId 的谓词调用 DbSet.FirstOrDefault() 时,出现以下异常: unable to create a constant value of type 's
我正在使用 EF5 将一些数据从一个数据库迁移到另一个数据库。我通常会使用 SQL 来做这样的事情,但是我需要其他功能(比如在 MembershipProvider 中创建用户)并且希望在 EF 中完
我创建了一个单独的项目并将我的模型复制到这个项目中。我引用了 using System.ComponentModel.DataAnnotations 我的模型定义如下: public class F
上下文: 我有两个类在 SQL 中有两个对应的表。 系统信息 EF 版本: SQL 版本:2012 类 public class Employee { public Employee(
我有一个定义了主从关系的 Entity Framework 对象。详细信息对象集合有一个导航属性。 在稍后的代码中,我尝试使用 AutoMapper 将其中一个主对象映射到数据传输对象。但是,数据传输
有没有办法让这个通用 Context.SalesEntity.Where(t=>t.id==3).Delete(); 有点像 private void DoWork(Expression> predi
来自 NHibernate 背景 - 我有一些审计列来反射(reflect)谁最后编辑了一条记录,以及该编辑发生的时间。 我已经覆盖了 SaveChanges 以寻找一个公共(public)基类,并使
我是 EntityFramework 6 的新手,一直在 POCO 中遇到问题。 以下是我的代码 Domain.cs public abstract class BaseEntity { [K
我刚在单元测试项目中遇到一个问题,坚持认为它需要 EntityFramework 的引用,我确信它不需要它。其他项目正在引用单元测试项目正在引用/测试的项目/扩展方法,并且在不引用 EntityFra
下面的代码应该做什么?在此代码中添加包含表的目的是什么,它应该对与 PersonId 相关的 JobType 进行级联删除,还是只删除具有指定 PersonId 的 Person ? db.tblPe
我试图了解延迟加载在 Entity Framework 6 中是如何工作的。在我看来,延迟加载只适用于 DbContext,其中“to-be-loaded”属性已经存在访问过。请查看下面的示例 - 测
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: Entity Framework Validation EntityFramework有什么好的灵活的验证框
我是一名优秀的程序员,十分优秀!