title: ASP.Net MVC 3 - Bind Include/Exclude and validation
body: <p>Although I use Bind-Include to edit only a portion of an object properties, validation for properties that are not include is still firing, an my model state is invalid after a form submission.</p>
  
  <p>Here is a simplified version of my model:</p>
  
  <pre><code>public partial class MyObject
  {
      public int MyObjectId { get; set; }
      public int personId { get; set; }
      public string myString1 { get; set; }
      public Nullable&lt;int&gt; friend1Id { get; set; }
      public Nullable&lt;int&gt; friend2Id { get; set; }
  
      public virtual People person { get; set; }
      public virtual People Friend1 { get; set; }
      public virtual People Friend2 { get; set; }
  }
  </code></pre>
  
  <p>And I have a controller to edit only the friends (Friend1 and Friend2) on that object that looks like this:</p>
  
  <pre><code>[HttpPost]
  public ActionResult Assignation([Bind(Include = "friend1Id,friend2Id")]MyObject myObject)
  {
      if (ModelState.IsValid)
      {
          db.Entry(myObject).State = EntityState.Modified;
          db.SaveChanges();
          return RedirectToAction("Index");
      }
      ViewBag.friend1Id = new SelectList(db.People, "personId", "Name", myObject.friend1Id);
      ViewBag.friend2Id = new SelectList(db.Divisions, "personId", "Name", myObject.friend2Id);
      return View(myObject);
  }
  </code></pre>
  
  <p>On my view I simply have 2 dropdown lists to select friends, and a Save button. When I click on save however, my model comes back as invalid. If I look a the collections of properties inside ModelState, I find an error message stating that myString1 is required. myString1 is of type nvarchar(100) NOT NULL in the database, but I would have thought that there would be no validation for that field since I did not include it in my binding. Is my understanding of Bind wrong? Please bear with me, I am new to ASP.Net MVC. I am using MVC 3 and EF 4.1 and strongly typed views.</p>