I have a Scalar-valued function in my DB:
ALTER FUNCTION [dbo].[fx_fooFunct]
(@MyParam varchar(max))
RETURNS varchar(max)
AS
BEGIN
return @MyParam
END
>
Do you have your function mapped in EDMX? I guess you don't.
Run Update from database wizard in the designer and under stored procedures select your SQL function to import and follow this article to create helper method marked with EdmFunctionAttribute
to expose the SQL function for LINQ-TO-Entities.
Note: SQL functions are not supported in code-first / fluent-API. You need to use mapping with EDMX.
ExecuteFunction
is used to call features mapped in EDMX - it expects name of the mapped feature (function imports of stored procedures). MSDN says that it can also call mapped functions but I don't know how - it calls function import and SQL function import doesn't have any.