Why won't EF4 generate a method to support my Function Import?

陌路散爱 提交于 2019-12-12 20:59:57

问题


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

)


回答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)



来源:https://stackoverflow.com/questions/4575005/why-wont-ef4-generate-a-method-to-support-my-function-import

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!