I have a DB that looks like this:
Houses
- HouseId
Rooms
- RoomId
HouseRooms
- HouseRoomId
- HouseId
- RoomId
class House
{
[Key]
public virtual int HouseId{ get; set; }
public DbSet<HouseRoom> Rooms{ get; set; }
}
class HouseRoom
{ [Key] public virtual int HouseRoomId{ get; set; }
public virtual int HouseId{ get; set; }
public virtual int RoomId{ get; set; }
[ForeignKey("RoomId")]
Public Role RoomInfo {get; set;}
}
class Room
{
[Key]
public virtual int RoomId {get; set;}
public string RoomName {get; set;}
}
I just need the House entity/mode to load all the rooms records. Noticed that the JOIN table has a PK name HouseRoomId but this is not the key that need to match the key in House. House.HouseId need to match HouseRoom.HouseId.
How can I get this to work?
Roombe in more than 1House?