views:

3419

answers:

2

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>
A: 

Open your Entity Data Model in XML view and check to see if you have any

<!--Errors Found During Generation: warning XXXX: The table/view/stored proc .....MDF.dbo.StoredProcName' does not have .... -->

Tags

If you don't then search for your <Function Name="{Name}" /> tags, and also do a search for that {Name}. Check to make sure nothing seems out of place.

If you can't find any problems, post those tags and your store procedure in your question.

bendewey
I checked the entity data model and there are no errors. I have edited my question with the tags related to the stored procs.
Satish
A: 

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: http://stackoverflow.com/questions/578536/function-imports-in-entity-model-with-a-non-entity-return-type

Roman Bataev