我创建了一个 SQL 表和一个 EF Fluent 映射,如下所示:
CREATE TABLE [dbo].[Application] (
[ApplicationId] INT IDENTITY (1, 1) NOT NULL,
[Name] NVARCHAR (50) Not NULL,
[DataVersion] ROWVERSION,
CONSTRAINT [PK_dbo.Application] PRIMARY KEY CLUSTERED ([ApplicationId] ASC)
);
我的 EF Fluent API 如下所示:
public class ApplicationConfiguration : EntityTypeConfiguration<Application>
{
public ApplicationConfiguration()
{
Property(a => a.Name)
.IsRequired()
.HasMaxLength(35);
Property(p => p.RowVersion).IsRowVersion();
}
}
我的班级看起来像这样:
public class Application
{
public int ApplicationId { get; set; }
public string Name { get; set; }
public virtual ICollection<TestAccount> TestAccounts { get; set; }
xxxxxxx
}
有人可以告诉我如何在课堂上定义 RowVersion 吗?