0

I have a device class, computer class and a virtualdesktop class. Every computer is a device and every virtualdesktop is a computer. I want to add a property to my virtualdesktop that references another device of type computer indicating where the virtual device is hosted. I am using POCOs with Entity Framework 5.0 in a Code First environment. How should I add this property to my virtualdesktop class below ? Is this a self-referencing relationship ?

[Table("devices")]
public class device 
{
   public int DeviceId { get; set; }
   public string Description { get; set; }
   public string IPAddress { get; set; }
}

[Table("computers")]
public class computer : device
{
    public string OperatingSystem { get; set; }
    public string OS_LicenseKey { get; set; }
}

[Table("virtualdesktops")]
public class virtualdesktop : computer
{
 //Should I do this
  public Computer Computer {get; set;}

 //Or should I do this
  public int ComputerId {get; set;}
}
4

1 回答 1

0

你需要两者。

阅读本文了解更多详细信息,包括如何设置可选和多对一关系。

于 2013-05-22T01:11:57.817 回答