Quantcast
Channel: Visio General Questions and Answers for IT Professionals forum
Viewing all articles
Browse latest Browse all 2333

How to fix Error: Refresh ObjectStateManager entries in MVC 4

$
0
0

I want to  insert into 2 table in 1 controller: example: 

db.Entry(record).State = EntityState.Added;
db.SaveChanges();
//
db.OtherTable.Add(newRecord);
db.SaveChanges(); //Error here
Then, i got this error: 

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




Viewing all articles
Browse latest Browse all 2333

Trending Articles