How do I make a self reference in Entity Framework Code First? -


i have device class, computer class , virtualdesktop class. every computer device , every virtualdesktop computer. want add property virtualdesktop references device of type computer indicating virtual device hosted. using pocos entity framework 5.0 in code first environment. how should add property virtualdesktop class below ? 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   public computer computer {get; set;}   //or should   public int computerid {get; set;} } 

you need both.

read this more details including how set optional , many 1 relationships.


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

php - Dynamic url re-writing using htaccess -

java - Multi-Label Document Classification -