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
Post a Comment