public class User
{
[Key]
public int UserId { get; set; }
public string UserName { get; set; }
}
public class Building
{
[Key]
public int BuildingId { get; set; }
public string BuildingName { get; set; }
}
public class UserBuildings
{
//these are the foreign keys
public int UserId { get; set; }
public int BuildingId { get; set; }
public int BuildingQuantity { get; set; }
}
I’ve been looking at other examples with two forgein keys but they don’t seem to answer my question.
In the UserBuildings table, both the UserId and BuildingId are required to make the record in the UserBuildings table unique. (There will be no two records with the same UserId and BuildingId, although they may have the same of one of them)
This should do it