Entity framework is not recognizing concurrency [concurrencyCheck] attribute in my MVC core 2 web app RRS feed

  • Question

  • User-1626688284 posted


    Saturday, September 1, 2018 6:31 AM

All replies

  • User475983607 posted

    Optimistic concurrency works as outlined in the reference documentation.


    I suggest that you create a test project according to the docs above.  That will give you a known working example.

    Try to apply the same to your project.  If you are still having trouble and need assistance, post sample code that reproduces the behavior.  That will help us help you troubleshoot the issue. 

    I've seen posts like this where optimistic concurrency is working but the test were flawed.

    Saturday, September 1, 2018 11:03 AM
  • User1120430333 posted

    Myself personally, I never fooled with concurrency with or without  an ORM in using optimistic concurrency. I always use pessimistic concurrency that never fails.   

    Saturday, September 1, 2018 11:27 AM
  • User-1626688284 posted


    Saturday, September 1, 2018 2:55 PM
  • User-1626688284 posted


    Saturday, September 1, 2018 3:09 PM
  • User475983607 posted

    So you are asking the community to debug chapter 11? 

    How about simply reading the ASP Core doc linked in my first post as we know it works.  Also, can you explain how you are testing?

    Saturday, September 1, 2018 8:23 PM
  • User-1626688284 posted

    no not at all!  I removed it from my previous post as it probably made me look like a college student looking for answers, ha!

    my testing is simply having 2 web browsers open and going into the edit menu of the same item on both browsers before any changes made.  I make a change in one browser and then make a change in the other browser.  the second change from the other browser should be flagged for concurrency violation as the first browser already changed the item before it.

    anyway, I believe I may have narrowed it down.  I looked at the logging information that EF produces for the SQL.  the concurrency tokens do work and EF is looking for concurrency as there are the appropriate WHERE clauses attached to the properties specified during the UPDATE.  the problem is that the EF is checking the current values in the database and not the original values.  I assumed the concurrency check data annotation would handle this automatically for me.  when I wrote concurrency in the update with ADO.NET I fed the function 2 objects, one with original values and the other one with the proposed changes.  in this design I am trying to implement the edit function in the controller only accepts the proposed object as an argument.

    my problem is probably a simple one but being new to MVC and EF, as well as the repository pattern I am trying to grasp has me confused.

    Thursday, September 6, 2018 3:12 AM
  • User-1626688284 posted

    disregard.  I found the solution.  I need to re-do the edit function to accept another parameter with the object containing the original value.

    Thursday, September 6, 2018 4:03 PM