2013-02-10 50 views
3

我应该有我的SQL Server数据库中的timestamp数据类型行。我使用的是代码优先的方法,所以我想从我的领域util类生成这个领域。时间戳生成的数据类型的代码

那么,如何声明这个属性作为数据库中的时间戳生成?

+0

你想要的数据库来存储时间戳上插入或更新? – 2013-02-10 09:11:15

回答

5

你可以使用一个字节数组饰有[Timestamp]属性:

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

您可能还需要签出following article

0

您可以使用此示例

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

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