If I have the following objects:
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; } }
The EF mapping is as follows:
modelBuilder.Entity<Application>() .HasMany(a => a.TestAccounts) .WithRequired(t => t.Application) .WillCascadeOnDelete(false);
The relationship between the two is that I can have applications with zero or many TestAccounts.
I am trying to describe fk relationship between two tables. Can someone explain what ".WithRequired" does. I do not understand why this is necessary.
user1679941
source share