首页 > 解决方案 > 实体框架执行功能不起作用

问题描述

尝试通过实体框架调用 SQL 函数,无论我尝试哪种方法,我总是遇到同样的错误

The FunctionImport 'fn_SearchEmployer' could not be found in the container 'MyDatabase'.

我的代码是

public virtual ObjectResult<EmployerModel> EmployerSearch(string employerName, int userId)
    {
        var employerNameParam = new ObjectParameter("employerName", employerName);
        var userIdParam = new ObjectParameter("userId", userId);
        return ((IObjectContextAdapter) this).ObjectContext.ExecuteFunction<EmployerModel>("fn_SearchEmployer", employerNameParam, userIdParam);
    }

任何想法将不胜感激!

标签: c#asp.netsql-serverentity-framework

解决方案


推荐阅读