![](/img/trans.png)
[英]NullReferenceException in EF 5-6.1.1 with two navigation properties to the same type
[英]EF 6 Navigation property between two objects of the same type
我有一个名为Booking的EF数据库模型
public class Booking
{
public int ID { get; set; }
public string Name { get; set; }
// some other properties...
}
我需要将两个不同的预订链接在一起,如何创建一个导航属性,使我在每个预订之间建立链接?
例如,预订A需要导航属性到预订B,反之亦然,预订B需要导航属性到预订A。
谢谢。
我想你可以像另一个导航属性一样:
public class Booking
{
// Your current code and...
// If you want One to One:
public virtual Booking RelatedBooking { get; set; }
// but if it's One to Many:
public virtual ICollection<Booking> RelaitedBookings { get; set; }
}
希望对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.