我正在针对SQL Server数据库使用实体框架构建API。我有2个表/实体,如下所示:
ParentTable{
Id INT Primary Key
RowVersion BYTE
}
ChildTable{
ParentKey INT Foreign Key (ParentTable)
SomeField NVARCHAR
SomeOtherField NVARCHAR
}
class ParentEntity{
string someOtherField
ICollection<ChildEntity> childReference
}
在保存Parent对象时,我想检查Rowversion以处理任何并发问题。但是我发现,当仅在父对象中修改子实体时,父项上的rowversion不会更改。我将如何解决这个问题?