سوال: کلید خارجی یک جدول از خود جدول

ساخت وبلاگ
سلام
دوتا کلاس زیر را داریم

public class City
{
public City()
{


}
public int CityId { get; set; }
public string Name { get; set; }
public int CityTypeId { get; set; }
[ForeignKey(nameof(CityTypeId))]
public virtual CityType CityType { get; set; }
public int ParentId { get; set; }
}


public class CityType
{
public CityType()
{


}
public int CityTypeId { get; set; }
public string Name { get; set; }
public virtual ICollection<City> Cities { get; set; }


}

که

public int ParentId { get; set; }

که id خود جدول می باشد
چگونه می توانم تعریف کنم که ارجاع از خود id همین جدول است
برنامه در mvccore است
تمپوs...
ما را در سایت تمپوs دنبال می کنید

برچسب : نویسنده : خنج tempos بازدید : 144 تاريخ : چهارشنبه 24 آبان 1396 ساعت: 8:41