This is the current basic code :
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(Registration registration)
{
if (Mode
Attach it to the context in the Unchanged
state, and only set Date
as modified.
if (ModelState.IsValid)
{
db.Registrations.Attach(registration); // attach in the Unchanged state
db.Entry(registration).Property(r => r.Date).IsModified = true;
// Date field is set to Modified (entity is now Modified as well)
db.SaveChanges();
return RedirectToAction("Index");
}
You said the incoming entity only has Date
filled in, hopefully there's an Id too. :)