Entity Framework 4 ile çalışırken karşılaştığım hata "The selected stored procedure returns no columns"

"The selected stored procedure returns no columns" bu hatayı çözmek için aşağıdaki sayfada birden fazla çözüm yeralmakta ben sorunu sp'nin değerlerini table variable döndürerek hallettim.

Entity Framework 4 – The selected stored procedure returns no columns

You create a stored procedure, you bring it into your entity model, you start to create a function import, you click the “Get Column Information” button and you get “The selected stored procedure returns no columns.”

The reasons I’ve seen for this are:

The solutions I’ve found are:

For #1


  1. You are returning your result set using dynamic sql, so EF can’t figure out at design time what the shape of the results will be.

  2. You are selecting from a temp table and EF can’t figure out the shape of the results at design time.

  3. Your stored procedure crosses databases and although you have all the rights you need in the database containing the sproc you don’t have the necessary rights to the database objects in the other database.  E.g., you don’t have select rights on a table in the other database.


  1. Alter your sproc so the result set structure can be figured out at design time. E.g., put the results into a table variable and select from that.

  2. Create a dummy sproc with the same name and signature as the final sproc that contains a select statement which creates a result set with the desired structure. (E.g., select cast(1 as int), cast(“a” as varchar(20)) … etc.) Refresh your entity model and add the function import – EF will see the structure and you can create the Entity to receive the results. Now replace the dummy sproc in the database with your final version.

For #2


  1. Use a table variable instead of a temp table

For #3

  • Give the user that is calling the sproc the correct rights in the other database or databases.

    1. Give the user that is calling the sproc the correct rights in the other database or databases.

    I hope people find that useful.

    Read more at mysoftwarenotes.wordpress.com
     

    Yorumlar

    Bu blogdaki popüler yayınlar

    22.06.2020 - 26.06.2020 arası işler

    Asp.net RestSharp ile data post etmek

    List Box Item içindeki elemanları aşağı veya yukarı taşımak