Entity Framework: TimeStamp fields not recognized for optimistic concurrency model

Today, while working with Entity Framework, I noticed through SQL Profiler that my update queries were not using timestamp field. I looked into my model and found that my timestamp fields have Concurrency Mode property set to None. It was quite strange; The entity model was auto generated and I wonder why the EF designer could not identify my timestamp field (I remember Linq To SQL designer automatically took care of such fields). Anyway, I changed Concurrency Mode to Fixed and it worked great. So, as a final note, when generating entity model from database, don’t forget to set appropriate concurrency modes for your timestamp fields as it is not done by the designer itself.

setting concurrency mode for timestamp field

Advertisements

One Response to “Entity Framework: TimeStamp fields not recognized for optimistic concurrency model”

  1. Moby Disk Says:

    This sounds like you successfully generated the model from the database when using a timestamp field. When I do that, the resulting SQL script creates a binary field, not a timestamp field. Were you really able to generate a database from this model?

    — Creating table ‘Cars’
    CREATE TABLE [dbo].[Cars] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Something] nvarchar(50) NOT NULL,
    [timestamp] binary(8) NOT NULL
    );


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: