title: What is the Real Advantage to ScaffoldColumn Attribute set to False in MVC 3 Model ID Properties
body: <p>I’m new to MVC and when I built my model classes for a code first approach each key ID column had the attribute <code>[ScaffoldColumn(false)]</code> set. I did this because I didn’t want the IDs displayed in the views obviously, and I know that a work around to this problem would be deleting the HTML generated by the UI in each view that contains an ID field.</p>
  <p>The problem I ran into by using <code>ScaffoldColumn</code> set to <code>false</code> in the Models was first noticed when an Edit method for a view was fired off, and I received this error: Store update, insert, or delete statement affected an unexpected number of rows (0). When I ran the code in debug the ID property was in fact set to zero as indicated in my view Edit <code>HttpPost</code> method.</p>
  <p>My Question that I hope someone might elaborate on, is what’s the point in having an attribute like <code>ScaffoldColumn</code> in MVC if the ID is not being sent to a controller method(s) like in this case an Edit <code>HttpPost</code>? Should I just go about this the old fashion way, and delete the HTML markup in each view created by the MVC temples generated when this attribute is not added to a key/foreign key properties?</p>
  <p>The work around I found if you set this attribute to <code>false</code> was adding an ID param to each <code>HttpPost</code> method, and than setting the appropriate ID property field prior to calling <code>SaveChanges()</code>.</p>