I have an older website (written in web forms in VB and ADO) that I would like to re-write with MVC core in C# and entity framework. I have the app working and it pulls data from the existing database with entity framework but it is not catching concurrency at all.
some things to consider: I have the [concurrencyCheck] attributes attached to the properties in the model.
under the nuget package manager it states that entity framework is not installed for the project but this must be a mistake? I am learning MVC core 2 at the moment and i came from VS 2012 to 2017. when I install entity framework from the nuget package manager (latest stable version is 2.1.2 it will show that it is going from version 2.03 to this latest version so this leads me to believe that version 2.03 is running by default? if so it is not showing under the dependencies.
the existing database was written in sql server 2012 full student version, uploaded to a hosting provider and backed up. the .BAK file was restored to sql localDb so I can open it with the free version of sql 2017. this same localDb file is used to pull in data in my project so I can follow along with the book I purchased for MVC core 2.
everything is working fine with the exception of the concurrency. I created the CRUD controller with success. I added the try and catch block to this CRUD controller's http POST version of the edit to catch concurrency and added the data annotations to the model class that represents the table.
the model class was created by hand to mimic the data table. so the book teaches code first but since I already had the existing database I had to write it code first but not do the migrations. basically the connection string was all that was needed.
maybe the LocalDB version of my database cannot do concurrency?...
i tried the ConcurrencyCheck attribute and it does not work. MVC core 2 with EF core. the ConcurrencyCheck annotation is there. I even have a try catch block for DbUpdateConcurrencyException. it just seems that the application is happily changing values and not even bothering to check for optimistic concurrency. I do not want to deal with migrations and am working with an existing sql server database so adding the timestamp option into the table itself I would like to avoid for now. everything just seems to be in place but it is simply not throwing or catching the optimistic concurrency error or being ignored all together.