Solution for error "Store update, insert, or delete statement affected an unexpected number of rows" .

When creating website via asp.net mvc3, got below blocking issue,  attached solution for it:

error:

error appear on the Edit.cshtml, error message as following:

Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. Refresh ObjectStateManager entries.

solution:

add: @Html.HiddenFor(model => model.CourseId, "CourseId") in the Edit.cshtml

原文地址:https://www.cnblogs.com/zcm123/p/3107118.html