次のオブジェクトがある場合:
public class Application
{
public int ApplicationId { get; set; }
public string Name { get; set; }
public virtual ICollection<TestAccount> TestAccounts { get; set; }
}
public class TestAccount
{
public int TestAccountId { get; set; }
public int ApplicationId { get; set; }
public string Name { get; set; }
public virtual Application Application { get; set; }
}
EFマッピングは次のようになります。
modelBuilder.Entity<Application>()
.HasMany(a => a.TestAccounts)
.WithRequired(t => t.Application)
.WillCascadeOnDelete(false);
これら2つの関係は、TestAccountがゼロまたは多数のアプリケーションを使用できることです。
2つのテーブル間のfk関係を説明しようとしています。誰かが「.WithRequired」が何をするのか説明できますか?なぜこれが必要なのかわかりません。