Entity Framework code first with TimeStamp type

Patrick Desjardins picture Patrick Desjardins · Sep 27, 2012 · Viewed 16.3k times · Source

I am using SQL Server 2008 R2 and Entity Framework 5.0. When the database is generated, I cannot add my property of type TimeStamp without having the following error: There is no store type corresponding to the conceptual side type

'Edm.Time(Nullable=True,DefaultValue=,Precision=)' of primitive type 'Time'.

I have set the Entity Configuration to the type time or timestamp without success

Property(x => x.RestBetweenSet).HasColumnType("timestamp");

When I go in the Sql Server Management Studio and edit the table I can set a column of timestamp.

What do I need to do to have Entity Framework code first be able to generate this column?

Thank you

Answer

Eric J. picture Eric J. · Sep 27, 2012

You should declare your time stamp property as follows in your code first class:

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