I'm using a EF with .Net Core 2.2. And I cannot figurated out how to solve the following problem:
I have the PQL and PM fields, these fields are the key of a user (Based in the table User). So, How I can create two relations of two fields to the same field (In the secondary table) using EF...
Example, a requirement is to create a query to get all projects per user, where the user be the PM or the PQL...
The main table is:
public class ProjectHeader
{
[Key]
public int IdProjectHeader { get; set; }
[StringLength(200)]
public string ProjectName { get; set; }
[ForeignKey("FK_IdUser")]
[Column("IdUser")]
public int PM { get; set; }
[ForeignKey("FK_IdUser")]
[Column("IdUser")]
public int PQL { get; set; }
// NOT LINK WITH USER TABLE CORRECTLY
public User User { get; set; }
}
The User table is:
public class User
{
[Key]
public int IdUser { get; set; }
[Required]
[StringLength(100)]
public string UserName { get; set; }
[Required]
[StringLength(50)]
public string ShortName { get; set; }
[Required]
[StringLength(50)]
public string Email { get; set; }
}