You have 2 options.
Use attributes as you have, for example:
[ForeignKey("PatientContact"), Column(Order = 0)] public int Person_ID{ get; set; } [ForeignKey("PatientContact"), Column(Order = 1)] public int Patient_ID{ get; set; } public virtual PatientContact PatientContact { get; set; }
Use model builder (free api)
modelBuilder.Entity<Event>() .HasRequired(p => p.PatientContact) .WithMany() .HasForeignKey(p => new {p.Person_ID, p.Patient_ID});
Luke mcgregor
source share