locked
Cannot execute stored procedure with ADO.NET Entity Framework RRS feed

  • Question

  • I created a simple stored procedure that receives a customer id and returns the data from this client. I imported the stored procedure to an entity model but it gives me this error "Error 146: Return type is not valid in FunctionImport 'spCliente'. The FunctionImport must return a collection of scalar values ​​or a collection of entities.". I try to create a FunctionImport but I did not succeed, also try to change the type of value, stated as I could run this stored procedure with EntityFramework.
    Thursday, May 16, 2013 4:56 PM

Answers

  • You have to specify the return type of the stored procedure when you create the function import. If the stored procedure returns the same number of columns as any of your object choose the object as your return type from Entities Dropdown. If the object is custom then click on the GetColumninformation to see the columns and create a new complex type or chose an existing complex type.

    Look at this link for the screenshot (I am giving this link only for you to see the screen shot of AddFunctionImport )

    http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/e7f598a2-6827-4b27-a09d-aefe733b48e6/

     

    • Proposed as answer by Chester Hong Tuesday, May 21, 2013 8:24 AM
    • Marked as answer by Chester Hong Wednesday, May 29, 2013 9:41 PM
    Thursday, May 16, 2013 9:05 PM

All replies

  • You have to specify the return type of the stored procedure when you create the function import. If the stored procedure returns the same number of columns as any of your object choose the object as your return type from Entities Dropdown. If the object is custom then click on the GetColumninformation to see the columns and create a new complex type or chose an existing complex type.

    Look at this link for the screenshot (I am giving this link only for you to see the screen shot of AddFunctionImport )

    http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/e7f598a2-6827-4b27-a09d-aefe733b48e6/

     

    • Proposed as answer by Chester Hong Tuesday, May 21, 2013 8:24 AM
    • Marked as answer by Chester Hong Wednesday, May 29, 2013 9:41 PM
    Thursday, May 16, 2013 9:05 PM
  • styven did you resolve the issue?
    Monday, May 20, 2013 3:24 PM