Simple Code
Simple Code

Reputation: 2584

How to create RowVersion column for optimistic concurrency using model first approach?

I am working on a legacy web app which implements model first(edmx file) approach using Entity Framework.

I need to implement optimistic concurrency, so I have added this field as following:

enter image description here

and inside the database has been created as binary(8) type. But when I try to update the entity is getting updated but the VersionRow values is not updated(no new value generated).

P.S

When I added the column I have binded default value as 0x0000000000000000 because it does not allow null values.

Upvotes: 1

Views: 680

Answers (1)

Simple Code
Simple Code

Reputation: 2584

Yea I solved it this way:

1) I changed the type of RowVersion column from Binary(10) into timestamp inside SqlServer.

2) In the property details inside the .edmx file I have put the property StoreGeneratedPattern of the property RowVersion as Computed.

Computed it means that a new value is generated on insert and update.

Now it became as following:

enter image description here

Upvotes: 2

Related Questions