为什么 EF4 不生成支持我的函数导入的方法?
我的数据库中有一个存储过程,它返回一个整数。我在模型中添加了函数导入。这出现在 EDMX 文件中:
<Function Name="GetTotalEntityCount" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo" />
但是,实际上没有为此生成任何方法。应该是顶级的吧?
using (MyContext context = new MyContext())
{
context.MyMethodShouldBeRightHere();
}
Intellisense 中什么也没有出现,我浏览过 Designer.cs 文件,里面什么也没有,并且反映了 DLL……什么也没有。代码生成器只是不生成任何代码来支持此存储过程。
我向数据库中添加了另一个表并更新了模型,并且该表进来了,因此模型将更新,它只是专门忽略此存储过程。
我已经尝试了我能想到的一切,并查阅了我能找到的所有资源,据我所知,我做的一切都是正确的。
我正在使用 EF4,数据库优先。 (无论如何,我很确定版本。这显示在生成的文件中
Runtime Version:4.0.30319.1
:)
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
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在模型浏览器中看到 GetTotalEntityCount 了吗?假设您这样做,右键单击它并选择“添加函数导入”并将其映射到标量类型。 (假设你还没有完成这一步)
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)