1

I use Entity Framework Model-First, I want to define a column for concurrency checking. One of my property named Version, I set its Concurrency Mode to 'Fixed', type to 'Binary', 'StoreGeneratedPattern' to 'Computed'. I want the column like timestamp, every time I insert or update, the database auto-generated a value for the record.

But, when I insert records, the Version property is not nullable, so, if I don't assign it a value, the SaveChanges will not work. How can I solve it? Is my solution of creating concurrency property correct?

Thanks in advance!

abatishchev
  • 98,240
  • 88
  • 296
  • 433
James
  • 2,570
  • 7
  • 34
  • 57

1 Answers1

1

Your expectations are correct but model first default database creation workflow is not. Current model first workflow never creates timestamp columns - it uses just varbinary. To force your expected behavior you must modify the workflow which is not an easy task: here is something related to the topic.

Community
  • 1
  • 1
Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670