【发布时间】:2013-05-22 00:25:38
【问题描述】:
我有一个设备类、一个计算机类和一个虚拟桌面类。每台计算机都是一台设备,每台虚拟桌面都是一台计算机。我想向我的虚拟桌面添加一个属性,该属性引用另一个计算机类型的设备,指示虚拟设备的托管位置。我在 Code First 环境中使用带有 Entity Framework 5.0 的 POCO。我应该如何将此属性添加到下面的虚拟桌面类中?这是自引用关系吗?
[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;}
}
【问题讨论】:
标签: entity-framework entity-framework-5 poco