none
model-first rowversion (timestamp) property RRS feed

  • Question

  • 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.

    Wednesday, March 7, 2012 10:54 AM

Answers

  • Hi rideronthestorm,

    Welcome to MSDN Forum.

    In code first, if you want to set a property as timestamp, you need use byte[] type on it, except that, you also need to add an annotation on that property to specify this property is timestamp. Here's a sample.

    class TestClass
    {
        public int ID { get; set; }
        public string Name { get; set; }
        
        [timestamp]
        public byte[] TimeStamp { get; set; } 
    }

    Best Regards

    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Friday, March 9, 2012 3:16 AM
    Moderator