Das Blog

Debugging one line at a time
$1*/ mo WordPress hosting! Get going with GoDaddy!
Menu
  • Home
  • Coding
    • Entity Framework
    • MVC
    • NHibernate
  • JavaScript
    • TypeScript
  • Hosting
  • SEO
  • Social
  • Database
    • MySql
    • SSIS
  • WP
  • Other
    • CakePHP
    • Error Messages
    • Google Maps
Home
Coding
Entity Framework
FunctionImport is not mapped to a store function Error
Entity Framework

FunctionImport is not mapped to a store function Error

Codex Discipulus May 9, 2019

Somehow I fell from the “happy path” creation of a stored procedure and the Entity Framework.

I had to make changes to a stored procedure and it got deleted from the Entity Data Model Xml file (*.edmx) resulting in the following error message when trying to compile the project:

System.Data.EntityCommandCompilationException
An error occurred while preparing the command definition. See the inner exception for details.

Inner exception:
{“The specified FunctionImport is not mapped to a store function and cannot be executed.”}

There is an easy solution to fix that error.

How to Solve FunctionImport Error Message

First open your edmx file and right click on the model that owns the stored procedure.

Click Add then  select “Add Function Import“.

Add the same Function Import name that is used in your Context file (if like me, the method was already created but messed up, otherwise is all new and it will be recreared anyways).

Select the Stored Procedure Name that you are trying to fix.

Choose the Entities and click OK.

A new window might pop up “Verify that the FunctionImport name is unique”.

If that is the case, and you get the “Verify that the FunctionImport name is unique” window popup, do the following:

Open your *.edmx file and right click over the model you want to update.

Select “Show in Model Browser”.

Now the Model Browser window opens up.

Go to: {myProject}.DataModel > EntityContainer: {somethingEntities} > Function Imports.

The function import causing the problem should be there, just delete it and save the *.edmx file.

Try to add the Function Import again.

Voila! no issues this time.

Save the *.edmx file and recreate the context file (by making a simple non-invasive change like adding a space to the {myProject}.Context.tt file). make sure the new method:

public virtual ObjectResult<MyEntity> <MyEntity>_NameoftheSP(parametets) is present in your Context file.

After that I get no more errors at build time or runtime.

Share
Tweet
Google+
Linkedin
Stumble
Email

About The Author

Codex Discipulus

Hello, my name is David and I am a disciple of coding, always learning and always ready to help. Welcome to my blog, I hope you find it useful, please send your comments and share an article with your friends.

10 Comments

  1. Peter K.

    Thanks! That saved me some time. 🙂

    June 8, 2011
    • DaCoder

      No problem, glad to help. Thanks for your comment.

      June 9, 2011
  2. David

    Thanks man, really useful 😀

    July 26, 2011
  3. John H

    I see this happening every time I make a change to the data model. Is there a setting that torches all my stored procedure mappings every time I make a change? It’s been pretty consistent and it makes me wonder if EF is worth the effort. It’s been a huge time savings, but if I have to manually remap every single stored procedure every time I make a change to the data model, it’s going to outlive its usefulness quickly.

    November 22, 2011
  4. Kamil

    Thanks for the info. Stupid visual studio…

    April 25, 2012
  5. Rod

    Thank you for burning the brain cells on this issue!

    November 2, 2012
  6. Robert J. Good

    Thanks for the help!

    I did have a situation, where I would 1. Delete the entity, 2. Re-add it, 3. The error would still show up.

    What I had to do was:
    1. Right click the .edmx file in Solution Explorer.
    2. Click OpenWith-TextEditor
    3. Search on the function in the error message: Insert
    4. Manually delete all lines between

    This happened when I renamed an underlying table view, and the .edmx had ‘abandoned’ old functions.

    January 23, 2013
  7. Kim P

    I had this same/similar issue where you could see both the stored procedures and function imports but they were still disconnected. I happened to trip across the solution once I looked at the properties windows for each function import and noticed the stored procedure name property was missing for each. Once I populated these fields all was working well again.

    Regards,
    Kim

    November 1, 2014
  8. Cuong Tran

    thanks!

    September 7, 2016
  9. thiru reddy

    Thanks a lot it help to me.

    April 6, 2018

Leave a Reply

Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

  • Hosting ASP.Net Core 3.x Worker Service as …
    Using the Worker template now is possible to host an …
  • Calling an HTTPS WCF Service from Net …
    We all know how to call a WCF service from …
  • How to Add a VS Code Project …
    Let’s try to add a Visual Studio Code project to …
  • Step by Step Token based Authentication in …
    Token Authentication is a very popular method to secure a …
  • How to Ignore NuGet Packages in TFS …
    This should be a short post. It is really just …

Categories

  • CakePHP
  • Coding
  • Database
  • Entity Framework
  • Error Messages
  • General
  • Google Maps
  • Hosting
  • JavaScript
  • MVC
  • MySql
  • Net Core
  • NHibernate
  • SEO
  • SSIS
  • TypeScript
  • Wordpress

Tags

ActiveDirectory analytics apps aspnet CakePHP coding database projects design patterns entity framework error messages fatcow first steps ftp github gitlab godaddy google maps api hangfire Hosting iis7 java javascript membership MVC MySql NHibernate nuget nuget packages oracle owin repository SEO sharp ssis t4 tfs thesis token authentication typescript vs2010 vs2015 vs2017 web api Wordpress wp-pagenavi

Das Blog

Debugging one line at a time
Copyright © 2020 Das Blog
ScottsdaleWebStudio.com © All Rights Reserved 2017