实体框架代码首先使用TimeStamp类型

Pat*_*ins 6 .net entity-framework sql-server-2008 asp.net-4.0 entity-framework-5

我正在使用SQL Server 2008 R2和Entity Framework 5.0.生成数据库时,我无法在没有以下错误的情况下添加TimeStamp类型的属性:没有与概念方类型对应的商店类型

原始类型"时间"的'Edm.Time(Nullable = True,DefaultValue =,Precision =)'.

我已将实体配置设置为类型时间或时间戳,但未成功

Property(x => x.RestBetweenSet).HasColumnType("timestamp");
Run Code Online (Sandbox Code Playgroud)

当我进入Sql Server Management Studio并编辑表时,我可以设置一列时间戳.

要让Entity Framework代码首先能够生成此列,我需要做什么?

谢谢

Eri*_* J. 14

您应该在代码第一类中声明您的时间戳属性,如下所示:

[Timestamp] 
public Byte[] MyTimestamp { get; set; }
Run Code Online (Sandbox Code Playgroud)


Pat*_*ins 3

目前,我映射到 INT64 并忽略时间戳。就像在这篇文章中一样。

如果有更好的解决方案,欢迎补充。我还不会接受我的答案。