3

I should have timestamp datatype row inside my SQL Server database. I'm using code-first approach so I want to generate this field from my domain util class.

So, how to declare this property to be generated as timestamp in the database?

1
  • Do you want the database to store a timestamp on insert or update? Commented Feb 10, 2013 at 9:11

2 Answers 2

5

You could use a byte array decorated with the [Timestamp] attribute:

[Timestamp] 
public byte[] SomeTimestamp { get; set; }

You might also want to checkout the following article.

Sign up to request clarification or add additional context in comments.

Comments

0

you can use this sample

...
       public byte[] TimeStamp { get; set; }
    }

     public class UserModelConfiguration: EntityTypeConfiguration<User> {
            public UserModelConfiguration() {
                Property(p => p.TimeStamp).IsRowVersion();            
            }
        }

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.