I'm trying to use a stored procedure in the entity framework. I had the model created initially without the stored proc. I then went into Update Model from Database and selected the stored procedure I wanted and then added it through the function import. Now I can see the function in the model browser under Function Imports but when I try to call it on the object context I get the error saying 'xxModel' does not contain a definition for 'xxfunction'. Any idea what I could be doing wrong?
I don't see any errors in the file related to the proc.
Here are the tags for the stored procs in the edmx file
<Function Name="p_DeleteDealFacts" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo"> <Parameter Name="DealID" Type="int" Mode="In" /> <FunctionImportMapping FunctionImportName="DeleteDealFacts" FunctionName="InterceptModel.Store.p_DeleteDealFacts" /> </EntityContainerMapping>
Visual Studio generates the function code in the model's code-behind if and only if you specify the return to be an entity type. Scalar and null return types do not work. Looks like a bug to me. Here is the full story: Function Imports in Entity Model with a non-Entity Return Type