Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7901469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:13:36+00:00 2026-06-03T09:13:36+00:00

I’m new to MVC and when I built my model classes for a code

  • 0

I’m new to MVC and when I built my model classes for a code first approach each key ID column had the attribute [ScaffoldColumn(false)] 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.

The problem I ran into by using ScaffoldColumn set to false 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 HttpPost method.

My Question that I hope someone might elaborate on, is what’s the point in having an attribute like ScaffoldColumn in MVC if the ID is not being sent to a controller method(s) like in this case an Edit HttpPost? 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?

The work around I found if you set this attribute to false was adding an ID param to each HttpPost method, and than setting the appropriate ID property field prior to calling SaveChanges().

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T09:13:37+00:00Added an answer on June 3, 2026 at 9:13 am

    Well, you don’t want it scaffolded as an editable field, but of course you do want it in the form, as you noticed. The solution is to just add it manually as a hidden field in the view. Something like this:

    @Html.HiddenFor(model => model.id)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm very new to MVC, and just building my first site, using NerdDinner as
Hi Everyone I am working on my first MVC 3 website built in C#
I've just created a new MVC 2 application that references both an entity model
I have built a model in some of my MVC websites to assist with
We recently added a new TeamCity build agent. Because it doesn't have ASP.NET MVC
i'm new to asp.net mvc.. so basically i just build up a two page
At my company we're about to build a new site using ASP.NET MVC. My
I have started a new mvc project and clicked on project\properties\web - use local
I am new MVC user and I am trying to make shopping cart as
Basically what the title says. I created a new MVC application. I'm trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.