public class Email
{
public int Id { get; set; }
/// ...
public int? ReplyTo { get; set; }
public int? ForwardOf { get; set; }
}
我想通過級聯洗掉配置ReplyTo并ForwardOf成為 FKEmail.Id屬性。
試過這個:
e.HasOne(nameof(Email.ReplyTo)).WithMany().OnDelete(DeleteBehavior.Cascade);
但它給出了一個錯誤
The specified type 'System.Nullable`1[System.Int32]' must be a non-interface reference type to be used as an entity type.
我不希望有型別的導航屬性,Email因為它們永遠不會被我的代碼使用。
uj5u.com熱心網友回復:
這應該允許陰影導航屬性:
.HasOne<Email>()
.WithMany()
.HasForeignKey(x => x.ReplyTo)
.OnDelete(DeleteBehaviour.Cascade);
盡管我不確定您是否想要對這種關系進行洗掉級聯。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/390085.html
