Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7963217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:33:48+00:00 2026-06-04T05:33:48+00:00

I am trying to implement the solution given in Handling Concurrency with the Entity

  • 0

I am trying to implement the solution given in Handling Concurrency with the Entity Framework in an ASP.NET MVC Application .

The article says:

Adding a Tracking Property to the Department Entity

In Models\Department.cs, add a tracking property:

[Timestamp] 
public Byte[] Timestamp { get; set; }

The Timestamp attribute specifies that this column will be included in the Where clause of Update and Delete commands sent to the database.

Since I’m using a model first approach, I followed steps 1 – 5 outlined in Creating a Timestamp column with Entity Framework

  1. Add a property named “Timestamp” to the entity in EF’s model
  2. Set the type to binary
  3. Set nullable to false
  4. Set StoreGeneratedPattern to Computed
  5. Set ConcurrencyMode to Fixed

When I update my code from the database model, the Models\Department.cs now contains

    public virtual byte[] Timestamp
    {
        get;
        set;
    }

Then I used the metadata class to specify the Timestamp attribute:

// Metadata for Department entity
public class DepartmentMetadata
{
    [Timestamp]
    public byte Timestamp { get; set; }
}

Q1. I tested whether the value of the Timestamp column is changing in case of row edits. It isn’t.

EDIT 1 The problem was caused because the SQL Server column type was binary, where it should have been of type timestamp. Changing the data type fixed the issue of the Timestamp column not getting updated.

Q2. I was trying to modify the same entity (using “Open in new tab”) to see if an OptimisticConcurrencyException is thrown. It isn’t. What am I doing wrong? Please help me understand, thanks.

Screenshot of my <code>Timestamp</code> property

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T05:33:49+00:00Added an answer on June 4, 2026 at 5:33 am

    The problem was caused because I had one ObjectContext per HTTP session, and so opening a new tab and testing it would NOT cause a concurrency exception.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying excessively hard to implement a good open id solution into asp.net
I am trying to implement the solution given in GetSaveFileName() not returning path of
I am trying to implement a solution to the following problem with vectors (arrays)
I'm trying to implement a solution using .htaccess and wildcard subdomains so that http://subdomain.example.com
I am trying to implement a OTP solution in C# based on RFC 4226:
I'm trying to implement this accepted solution for displaying a custom error message: https://stackoverflow.com/a/5229581/141172
Just trying to implement a simple audit logging solution with Grails 2.0.2 and it
I'm trying to implement chained filter dropdown using just javascript - jquery. The solution
The background is : I am trying to implement an automated integration test solution.
I'm trying to decide how to implement a very basic licensing solution for some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.