title: How to update specific fields in asp.net mvc
body: <p>And this is the class I'm using. I used the db first approach. </p>
  
  <pre><code>public partial class Ingredient
  {
      public int id { get; set; }
      public string name { get; set; }
      public string desc{ get; set; }
      public byte is_deleted { get; set; }
      public int Ingredient_Type_id { get; set; }
      public int UOM_id { get; set; }
  }
  </code></pre>
  
  <p>I have this code, the scaffolded one that updates a record. </p>
  
  <pre><code>public ActionResult EditDetails(Ingredient ingredient)
  {           
     if (ModelState.IsValid)
     {
        db.Entry(ingredient).State = EntityState.Modified;
        db.SaveChanges();
        return RedirectToAction("Index");
     }
     ViewBag.UOM_id = new SelectList(db.Unit_Of_Measurement, "id", "name", ingredient.UOM_id);
     ViewBag.Ingredient_Type_id = new SelectList(db.Ingredient_Type, "id", "name", ingredient.Ingredient_Type_id);
     return View(ingredient);
  }
  </code></pre>
  
  <p>From what I see and understand in the code above, it updates all the fields in the record. However, I want to only update the <code>name</code> and <code>desc</code> fields. How should I do this? I'm also new in doing this, so an explanation will be appreciated too. Thank you.</p>