TimeStamp attribute can be applied to only one byte array property of a domain class. TimeStamp attribute creates a column with timestamp datatype. Code-First automatically use this TimeStamp column in concurrency check.

Consider the following example.

using System.ComponentModel.DataAnnotations;

public class Student
{
    public Student()
    { 
        
    }

    public int StudentKey { get; set; }
     
    public string StudentName { get; set; }
        
    [TimeStamp]
    public byte[] RowVersion { get; set; }
}
     

 

As you can see in the above example, TimeStamp attribute is applied to Byte[] property of the Student class. So, Code First will create a timestamp column RowVersion in the Student table as shown below.

Entity Framework Code-First(9.2):DataAnnotations - TimeStamp Attribute

相关文章:

  • 2022-02-28
  • 2022-02-27
  • 2021-09-21
  • 2021-08-30
  • 2021-12-19
  • 2021-12-03
  • 2022-12-23
  • 2021-07-24
猜你喜欢
  • 2022-01-13
  • 2022-02-17
  • 2022-02-06
  • 2021-09-13
  • 2021-12-21
  • 2022-02-08
  • 2022-01-10
相关资源
相似解决方案