ここにあるソリューションを実装しようとしていますが、「Users」クラスを「EditUserViewModel」クラス (Users クラスよりもフィールドが少ないクラス) に置き換えて、この行に到達したら
db.Entry(users).State = EntityState.Modified;
このコードで
[HttpPost]
public ActionResult Edit(EditUserViewModel users)
{
if (ModelState.IsValid)
{
db.Entry(users).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
return View(users);
}
エラーが発生します
The entity type EditUserViewModel is not part of the model for the current context.
このエラーは、DBContext が EditUserViewModel クラスではなく Users クラスを使用しているためだと推測しています。手順が不足していますか、またはこれを修正する方法はありますか?