小编Man*_*ala的帖子

参数类型“Edm.String”和“Edm.Int32”与此操作不兼容

我收到类似上面标签的错误,它将位于

返回视图(st.employees.Find(id));

仅在上面的地方,任何人都可以帮我解决这个问题!我的代码是

     namespace StartApp.Controllers
  {
public class EmployController : Controller
{
    StartEntities st = new StartEntities();
    //List
    public ActionResult List()
    {
        return View(st.employees.ToList());
    }
    //Details
    public ActionResult Details(int id = 0)
    {
        return View(st.employees.Find(id));
    }
    //Create
    public ActionResult Create()
    {
       return View();
    }


    [HttpPost,ValidateAntiForgeryToken]
    public ActionResult Create(employee e)
    {
        using(st)
        {
            st.employees.Add(e);
            try
            {
                st.SaveChanges();
            }
            catch
           {
               System.Diagnostics.Debug.WriteLine("Here is an error");
            }
        }
        return RedirectToAction("List");
    }
   //edit
    public  ActionResult Edit(int id = 0)
    {

           return View(st.employees.Find(id));

    }

    [HttpPost,ValidateAntiForgeryToken] …
Run Code Online (Sandbox Code Playgroud)

c# sql-server asp.net-mvc linq-to-entities entity-framework

5
推荐指数
1
解决办法
1万
查看次数