【发布时间】:2019-03-08 19:03:48
【问题描述】:
我正在尝试在Roles 表中编辑RoleName。一切正常,除了我收到 Entry 和 SaveChanges 方法没有定义的错误。我对System.Data.Entity 和EntityFramework 都有using 声明,所以我不确定问题是什么。我很确定我拥有所有正确的软件包和参考资料。
//Get Edit
[HttpGet]
public ActionResult Edit(Roles model)
{
return View();
}
//Put Edit
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(Comtrex_ICU.Models.Roles model, int RoleId,
Roles RoleName)
{
try
{
Roles db = new Roles();
db.Entry(RoleName).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("RolesIndex");
}
catch
{
return View();
}
}
【问题讨论】:
-
能否提供角色类的定义。似乎编译器无法在 Roles 类中找到两个方法:Entry 和 SaveChanges
-
为什么您的 POST Edit 签名有两个角色实例被传递给它?
Roles RoleName是什么?如何解决?
标签: c# asp.net model-view-controller crud