为什么我可以在Entity Framework数据模型中看到存储过程和标量函数,而不是我的控制器?

时间:2014-02-04 13:20:05

标签: c# sql-server asp.net-mvc entity-framework visual-studio-2012

我在MVC 3解决方案中创建了一个新项目,其中数据库优先实体框架模型映射到SQL Server 2008数据库。我在模型中包含了所有表,视图,存储过程等。我可以在查看数据模型时看到我想要使用的标量函数,但是当我尝试在我的控制器中使用proc或函数名作为对象时,Intellisense没有看到它并且应用程序出错了。在控制器中使用存储过程和函数需要做些什么吗?

 using System;
 using System.Collections.Generic;
 using System.Data;
 using System.Data.Entity;
 using System.Linq;
 using System.Web;
 using System.Web.Mvc;
 using Newtonsoft.Json;
 using System.Web.Security;
 using System.Data.Objects.SqlClient;
 using JobBoard.Models;
 using JobBoardDAL.Models;

 namespace JobBoard.Controllers
 {
     public class AccountController : Controller       
     {


    private DataModel db = new DataModel();

    public ActionResult Authenticate() {
        .....
        var x = db.IsUser(somevariable); // <---- Problem is here
    {

    }

}

}

1 个答案:

答案 0 :(得分:1)

您需要将SP和函数添加到edmx模型,并将它们映射到复杂类型。

请参阅here