Mapping foreign key in HasOptional().WithOptionalDependent() relation in Entity Framework 6
问题 I have the following data-model in Entity Framework 6.1.3: using System.Data.Entity; public class Student { public int Id { get; set; } public virtual Contact Contact { get; set; } } public class Contact { public int Id { get; set; } public virtual Student Student { get; set; } } public class MyContext : DbContext { protected override void OnModelCreating(DbModelBuilder builder) { builder.Entity<Contact>() .HasOptional(x => x.Student) .WithOptionalDependent(x => x.Contact)