Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework code first with TimeStamp type

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

like image 707
Patrick Desjardins Avatar asked Sep 26 '12 23:09

Patrick Desjardins


2 Answers

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

[Timestamp] 
public Byte[] MyTimestamp { get; set; }
like image 92
Eric J. Avatar answered Oct 16 '22 17:10

Eric J.


For the moment, I map to a INT64 and ignore the TimeStamp. Like in this post.

If they are better solutions, feel free to add. I won't accept my answer yet.

like image 3
Patrick Desjardins Avatar answered Oct 16 '22 19:10

Patrick Desjardins