6

I am developing Entity Framework based app. I am using model-first approach. I would like to handle the concurrency issues. As written in many articles I am going to do it by turning the ConcurrencyMode to fixed on a field which is a timestamp. At the moment I am facing the problem - I cannot add field (column) of type timestamp. How can I do it in model?

As written here:

http://social.msdn.microsoft.com/Forums/is/adodotnetentityframework/thread/1ed8d1e4-9d78-4593-9b10-33e033837af8\

I tried installiing Entity Designer Database Generation Power Pack, but still I see no possibility to have the timestamp generated from the model (I have even tried setting it manually in edmx file, but still I am not receiving timestamp fcolumn in generated database).

Please help.

abatishchev
  • 98,240
  • 88
  • 296
  • 433
rideronthestorm
  • 727
  • 1
  • 13
  • 32

2 Answers2

2

I think the database type timestamp maps to a Binary property type in EF.

My model's timestamp column is type Binary with length 8, fixed length true, StoreGenratedPattern is Computed.

EDIT: Actually not possible without changing the t4 template as explained here: Entity Framework timestamp Generate Database issue

Community
  • 1
  • 1
user917170
  • 1,591
  • 15
  • 28
0

EF 6.1, I have this:

public partial class DepartmentEFEntity
{

    Guid DepartmentUUID { get; set; }

    public byte[] TheVersionProperty { get; set; }
}

and then:

        modelBuilder.Entity<DepartmentEFEntity>().Property(o => o.TheVersionProperty).HasColumnType("timestamp").HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed).IsRowVersion();

When I script out the table, I get this:

CREATE TABLE [dbo].[Department](
    [DepartmentUUID] [uniqueidentifier] NOT NULL,
    [TheVersionProperty] [timestamp] NOT NULL
    )
IDisposable
  • 1,858
  • 22
  • 22
granadaCoder
  • 26,328
  • 10
  • 113
  • 146