我发现 EF 不需要 [Aggregated] 属性
诀窍是在 DBContext OnModelCreating 中设置关系
以销售订单为例
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
modelBuilder.Entity<Order>().HasMany(x => x.Lines).WithOptional(x => x.Order).WillCascadeOnDelete();
}
// 我多么希望在这里可以使用 WithRequired,但 XAF 不支持它。
确保 LinkNewObjectToParentImmediately 为真。
public partial class T474565WindowsFormsApplication : WinApplication {
public T474565WindowsFormsApplication() {
InitializeComponent();
// LinkNewObjectToParentImmediately = false;
}
https://www.devexpress.com/Support/Center/Question/Details/T474565