Friday, July 5, 2013

The function import cannot be executed because it is not mapped to a store function



This is very typical error you receive when your underlying database store is changed and there is no update made to EDMX file.
For example, I imported a stored procedure in edmx and saved it. After that I change the stored procedure and do not update edmx. I run the application and at runtime the error is encountered as - “the function import cannot be executed because it is not mapped to a store function”.
This error can be resolved easily by updating the edmx. Following is procedure to resolve the error –
Open the edmx and open Model Browser. Model browser can be opened as shown below.
 
Find the required stored procedure in model browser. The right click and select option – “Delete from Model” as shown below –
 
Now right click on any area on edmx file and select the option “Update Model from Database” option. The popup containing the list of Tables, View and stored procedure will appear. Select the earlier deleted stored procedure and click “Finish” on the pop up.
Now again open the model browser and find the added stored procedure. Right click on it and select the “Edit” option as shown below -
 
“Edit function Import” pop up will appear. For the selected stored procedure you will find that, return collection is having the two options which end with “Results1” and “Results”. Out of these two options select Results option and click OK.

This will resolve the error. Hope it helps.
Cheers…
Happy Importing!!!

10 comments:

  1. Thanks, I used this successfully.

    ReplyDelete
  2. Nice work. Thanks a lot. That saved me a lot of time :D.

    ReplyDelete
  3. Worked like a charm. You might want to add, hit UPDATE in your last step when you are editing function import to get the latest columns returned if the SP had some changes made.

    ReplyDelete
  4. Thanks a lot. worked for me

    ReplyDelete
  5. Thanks very much!

    ReplyDelete
  6. And another happy customer. Worked. Thank you!

    ReplyDelete
  7. I've tried this but its not working for me. When I follow this, I end up having to run the Generate Database from models command and then I lose the mapping to the stored procedure I brought back in.

    ReplyDelete
  8. Thank you Thank you Thank you! If I met you in person I'm gonna buy you a coffee :)

    ReplyDelete
  9. yes my issues solved thanks

    ReplyDelete