Friday, July 19, 2013

entity framework 4 function imports stored proc complex type return no column

Entity Framework will try to get the columns by executing your Stored Procedure, 
passing NULL for every argument. You can see this by putting a trace on your SQL 
Server.

So - first make sure your S_P will return something under these circumstances.
 Note it may have been smarter for Entity Framework to execute the Stored Proc
 with Default Values for arguments, as opposed to NULLS. Never mind - nothing
 we can do about that!
However - before trying to run the Stored Procedure, ER does this
SET FMTONLY ON
This will break your stored procedure in various circumstances, in particular, 
if it uses a temp table.
So, add to the start of your Stored Procedure:
SET FMTONLY OFF;
This worked for me - hope it works for you too.

No comments:

Post a Comment