asp.net mvc 3 - A first chance exception of type 'System.Data.OptimisticConcurrencyException' occurred in System.Data.Entity.dll -


Good afternoon, completely stumped on this one. Everything was recovering until I add more records to my database.

I get this error when I press edit:

Type 'system.Data.OptimisticConcurrencyException' is a first exception to System.Data.Entity.dll

< P> My code is as follows:

  Edit Public Functionality (int id) {From time to time = DB. time. Single (T = & gt; T.index == ID); See Return (Time); } // // Post: / Default 1 / Edit / 5 [HTPOST] Edit Public Action Result (Time Timing) {System.Diagnostics.Debug.WriteLine ("HERE"); If (ModelState.IsValid) {db.Times.Attach (time); Db.ObjectStateManager.ChangeObjectState (Time, EntityState.Modified); Db.SaveChanges (); Return Redirect Action ("Index"); } View return (time); }  

I was doing MVC programming for that long, so the laymans terms will be welcomed!

Thanks

I have started a new project and the whole of the controllers, The code is copied, it seems that has worked.

I think the main issue was to make a lot of changes to the model with the primary key etc. And basically it was bad for me.

Better database architecture needed !!!!


Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -