7
Próbowanie najpierw ustawić następującą relację z kodem struktury encji. Poniższy kod nie działa Próbowałem wielu odmian ... Czy ktoś ma wskazówkę?Mapowanie klucza obcego na klucze złożone w strukturze jednostki
CONSTRAINT [FK_EVENT_Contact] FOREIGN KEY (Patient_ID,[Contact_ID]) REFERENCES
[PatientContact](Patient_ID,Person_ID)
public class PatientContact
{
[Key, Column(Order = 0)]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public int Person_ID { get; set; }
public virtual Person Person { get; set; }
[Key, Column(Order = 1)]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public int Patient_ID { get; set; }
public virtual Patient Patient { get; set; }
}
public class Event
{
[Key]
public int Event_ID { get; set; }
[Required]
public int EventType_ID {get;set;}
public virtual EventType EventType { get; set; }
[ForeignKey("Patient")]
public int Patient_ID { get; set; }
public virtual Patient Patient { get; set; }
[ForeignKey("PatientContact")]
public int Contact_ID { get; set; }
public virtual PatientContact PatientContact { get; set; }
}
Witamy na przepełnienie stosu! Jaki błąd dostałeś? Co dokładnie próbujesz osiągnąć? – IronMan84