为什么EF4不会生成一个方法来支持我的功能导入? [英] Why won't EF4 generate a method to support my Function Import?

查看:87
本文介绍了为什么EF4不会生成一个方法来支持我的功能导入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的数据库中有一个存储过程,返回一个整数。我添加了一个函数导入到我的模型。这显示在EDMX文件中:

 < Function Name =GetTotalEntityCountAggregate =falseBuiltIn =falseNiladicFunction =falseIsComposable =falseParameterTypeSemantics =AllowImplicitConversionSchema =dbo/> 

但是,实际上没有为此生成方法。它应该是顶级的,对吗?

  using(MyContext context = new MyContext())
{
context.MyMethodShouldBeRightHere();
}

Intellisense中没有任何内容,我已经通过了designer.cs文件没有什么在那里,并反映了DLL ...没有。代码生成器只是没有生成任何代码来支持这个存储过程。



我在我的数据库中添加了另一个表并更新了模型,而 >进来,所以模型更新,它只是专门忽略这个存储的proc。



我已经尝试了我能想到的一切,并查阅我可以找到的每一个资源,并且尽可能接近我所说的,我正在做的一切正确。



我使用的是EF4,数据库优先。 (我确实在版本上,无论如何,这显示在生成的文件中:

 运行时版本:4.0.30319.1 

解决方案

你在模型浏览器中看到GetTotalEntityCount吗?假设你做,右键单击它并选择添加功能导入并将其映射到标量类型。 (假设你还没有完成这个步骤)


I have a stored proc in my database which returns an integer. I added a Function Import to my model. This appears in the EDMX file:

 <Function Name="GetTotalEntityCount" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo" />

However, no method actually gets generated for this. It should be top level, right?

 using (MyContext context = new MyContext())
 {
     context.MyMethodShouldBeRightHere();
 }

Nothing appears in Intellisense, I've gone through the designer.cs file and there's nothing in there, and reflected the DLL...nothing. The code generator is just not generating any code to support this stored proc.

I added another table to my database and updated the model, and that came in, so the model will update, it's just specifically ignoring this stored proc.

I've tried everything I can think of, and consulted every resource I can find, and as near as I can tell, I'm doing everything right.

I'm using EF4, database-first. (I'm pretty sure on the version, anyway. This shows up in the generated file:

Runtime Version:4.0.30319.1

)

解决方案

Do you see the GetTotalEntityCount in the model browser ? Assuming you do, right click it and choose Add Function Import and map it to a scalar type. (Assuming you've not done this step)

这篇关于为什么EF4不会生成一个方法来支持我的功能导入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆