asp.net mvc - mvc music store -


i'm trying mvc musicstore tutorial, , after part 6 when using edit i'm getting error:

store update, insert, or delete statement affected unexpected number of rows (0). entities may have been modified or deleted since entities loaded. refresh objectstatemanager entries. description: unhandled exception occurred during execution of current web request. please review stack trace more information error , originated in code.

exception details: system.data.optimisticconcurrencyexception: store update, insert, or delete statement affected unexpected number of rows (0). entities may have been modified or deleted since entities loaded. refresh objectstatemanager entries.

any idea why reason?

[httppost]  public actionresult edit(album album)  {      if (modelstate.isvalid)     {         db.entry(album).state = entitystate.modified;          db.savechanges();          return redirecttoaction("index");     }      viewbag.genreid = new selectlist(db.genres, "genreid", "name", album.genreid);     viewbag.artistid = new selectlist(db.artists, "artistid", "name", album.artistid);      return view(album); } 

it scaffold

make sure you're calling savechanges in-between inserts, updates, or deletes.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -