8

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

3 Answers 3

15

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

[Timestamp] 
public Byte[] MyTimestamp { get; set; }
Sign up to request clarification or add additional context in comments.

1 Comment

Hi, the problem is that we cannot use anymore all timestamp method if it's a Byte.
3

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.

1 Comment

So you wanted to store a Timespan rather than a Timestamp?
1

I am not sure I understand your question so well, but this how I generate timestamp fields using code first approach and entity framework

[Required, DatabaseGenerated(DatabaseGeneratedOption.Computed)]
public DateTime CreatedAt { get; set; }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.