Hi All,
I am using MVC 5 with EF 6.
In my application I chose Controller with views using Entity Framwork, which automatically creates the view and methods like below.
public ActionResult Edit([Bind(Include = "bigid,vcname,vcrate_phour,dateadded,datemodi,addedby,updatedby")] OT_Band_Master oT_Band_Master)
{
if (ModelState.IsValid)
{
oT_Band_Master.datemodi = DateTime.Now.Date;
oT_Band_Master.updatedby = Convert.ToInt32(Session["AdminID"].ToString());
db.Entry(oT_Band_Master).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
return View(oT_Band_Master);
}Suppose I just guess ( not sure ) that this error comes when don't provide all fields in Edit ActionResult.
Actually I don't need to update all fields as mentioned here (bigid,vcname,vcrate_phour,dateadded,datemodi,addedby,updatedby).
I just need to only 4 fields. 2 are I am mentioning here in code.
oT_Band_Master.datemodi = DateTime.Now.Date;
oT_Band_Master.updatedby = Convert.ToInt32(Session["AdminID"].ToString());
And other two it took from like below
@Html.EditorFor(model => model.vcname
Please suggest.
Thanks