我在MSSQL下表定義:RIA Services + Entity Framework 4 + POCO's:'時間戳字段是必需的'錯誤?
CREATE TABLE [User] (
[Id] bigint identity(1,1) NOT NULL,
[Email] nvarchar(256),
[PasswordHash] nvarchar(128) NOT NULL,
[PasswordFormat] int DEFAULT ((0)) NOT NULL,
[PasswordSalt] nvarchar(10) NOT NULL,
[Timestamp] timestamp
)
;
的EDMX屬性時間戳看起來是這樣的:(注意只有紅色屬性已手動箱變)
alt text http://i35.tinypic.com/2ez7g9k.png
我用t4模板自動生成POCO實體。 用戶實體看起來是這樣的:
public partial class User : IEntity
{
public virtual long Id
{
get;
set;
}
...
[TimestampAttribute]
[ConcurrencyCheck]
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "Autogenerated by T4.")]
public virtual byte[] Timestamp
{
get;
set;
}
...
}
在做對的ObjectContext一個「的SaveChanges」操作,我得到了用戶實體驗證錯誤,這就是所謂:需要時間戳字段
您確定SaveChanges上的Timestamp字段中有值嗎? – 2010-08-15 10:22:14
時間戳記字段應由SQL Server更新,而不是由RIA Client或Server代碼更新。我認爲在元數據中排除這個字段會起到訣竅的作用。我會告訴你這件事。 – 2010-08-15 11:26:35
+1我遇到了完全相同的問題。 – 2011-04-04 08:53:57