I have done this in the past by adding a timestamp field to the table in which you want to perform a concurrency check. (in my example, I added a column called ConcurrencyCheck)
Depending on your needs, there are two types of concurrency mode:
1 concurrency Mode: Fixed:
Then re-add / update the table in your model. For fixed concurrency, make sure your concurrency mode is set to your table when importing into your model: for example,

Then, to catch this:
try { context.SaveChanges(); } catch (OptimisticConcurrencyException ex) {
2. concurrency mode: No
If you want to handle your own concurrency check, i.e. raise the validation informing the user and not even allowing to save, then you can set the concurrency mode to None.
1. Make sure that you change the ConcurrencyMode in the properties of the new column that you just added to "No." 2. To use this in my code, I would create a variable to save the current timestamp on the screen on which you want to check the save.
private byte[] CurrentRecordTimestamp { get { return (byte[])Session["currentRecordTimestamp"]; } set { Session["currentRecordTimestamp"] = value; } }
1.On loading (assuming that you are using asp.net and not mvc / razor, which you did not mention above), or when you fill the screen with the data you want to edit, I would pull the current record to Change the value of ConcurrencyCheck in this variable that you created.
this.CurrentRecordTimestamp = currentAccount.ConcurrencyCheck;
Then, if the user leaves the record open, and someone else changes it in the meantime, and then they also try to save, you can compare this timestamp value that you saved earlier with the concurrency value that it is now.
if (Convert.ToBase64String(accountDetails.ConcurrencyCheck) != Convert.ToBase64String(this.CurrentRecordTimestamp)) { }