我的错误是db在上下文中不匹配。如何纠正。 [英] My error is db does not match in the context .How to rectify.
本文介绍了我的错误是db在上下文中不匹配。如何纠正。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
[HttpPost]
public ActionResult Create([Bind(Include = "EmpId,Name,Department,Mobile,Address")] employee Employee)
{
if (ModelState.IsValid)
{
dc.Employees.Add(Employee);
dc.SaveChanges();
return RedirectToAction("Index");
}
return View(Employee);
}
推荐答案
你的问题不清楚。您可以复制/粘贴调用此方法时得到的确切错误消息吗?
我的猜测是您的数据库结构与您的Employee模型不同。
Your question is unclear. Can you copy/paste the exact error message you get when calling this method?
My guess would be that your database structure differs from your Employee model.
这篇关于我的错误是db在上下文中不匹配。如何纠正。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文