EDIT 1:
This is the real code that I'm using to accomplish the scenario mentioned, is the following:
public class PacientePesquisa { [Key, Column(Order = 1)] [Required(ErrorMessage = Msg_Critica_Req_IDPesquisa)] [Display(Name = "Pesquisa")] public int IDPesquisa { get; set; } [ForeignKey("IDPesquisa")] public virtual Pesquisa Pesquisa { get; set; } [Key, Column(Order = 2)] [Required(ErrorMessage = Msg_Critica_Req_NRProntuario)] [StringLength(NRProntuario_MaxLength, ErrorMessage = Msg_Critica_Tam_NRProntuario)] [Display(Name = "Prontuário")] public string NRProntuario { get; set; } [ForeignKey("NRProntuario")] public virtual Paciente Paciente { get; set; } (...) public class Pesquisa { [Key] public int IDPesquisa { get; set; } (...) public class Paciente { [Key] [DatabaseGenerated(DatabaseGeneratedOption.None)] public string NRProntuario { get; set; } (...) And when running the "add-migration", I'm receiving the following error:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Data.Entity.ModelConfiguration.ModelValidationException: One or more validation errors were detected during model generation: System.Data.Entity.Edm.EdmAssociationConstraint: : The number of properties in the Dependent and Principal Roles in a relationship constraint must be identical.