Если у меня есть следующие объекты:Какая часть имеет .WithRequired играть в API EF Fluent?
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 Mapping выглядит следующим образом:
modelBuilder.Entity<Application>()
.HasMany(a => a.TestAccounts)
.WithRequired(t => t.Application)
.WillCascadeOnDelete(false);
Отношения между этими двумя, что я могу иметь приложения с нуля или многих TestAccounts.
Я пытаюсь описать связь fk между двумя таблицами. Может кто-нибудь объяснить, что делает «.WithRequired». Я не понимаю, зачем это нужно.