1

我有一个用户访问类:

public class UserAccess : CloneableBaseEntity<UserAccess>
{
    public int UserId { get; set; }
    public User User { get; set; }
    public int? SiteId { get; set; }
    public virtual Site Site { get; set; }
    public int? CostCenterId { get; set; }
    public virtual CostCenter CostCenter { get; set; }
    public int? ProductId { get; set; }
    public virtual Product Product { get; set; }
}

该类派生自基本实体:

public  class BaseEntity : ObservableObject
{
    [Key]
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public int Id { get; set; }
    public DateTime Created { get; set; }
    public int CreatedUserId { get; set; }
    public DateTime Changed { get; set; }
    public int ChangedUserId { get; set; }

    public BaseEntity()
    {
    }

}

Site、Product 和 CostCenter 公开此属性:

    public virtual List<UserAccess> UserAccesses { get; private set; }

当我更新我的数据库时,UserAccess 表中的列仍然不能为空。是什么导致了这种行为?

4

0 回答 0