C
C#2y ago
adnan307

❔ ef core foreign key problem

public class Player
{
public int Id { get; set; }
public Ban Ban { get; set; }
}

public class Ban
{
public int Id { get; set; }
public Player Player { get; set; }
public Player Admin { get; set; }
}
public class Player
{
public int Id { get; set; }
public Ban Ban { get; set; }
}

public class Ban
{
public int Id { get; set; }
public Player Player { get; set; }
public Player Admin { get; set; }
}
how i need to configure the foreign keys for this situation?
4 Replies
Saber
Saber2y ago
well I would expect that the Player entity would have 2 lists, one to represent the bans the player has recieved, and one to represent the bans they've given out. public List<Ban> Bans {get;set;} and public List<Ban> GivenBans {get;set;} then to configure it
adnan307
adnan307OP2y ago
is there a solution without the lists?
Angius
Angius2y ago
I'd say configure them on the Ban entity And configure the relationship with .HasOne(...).WithOne(...)
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server