Postgresql EF核心中的多重相关FK
我有Postgresql EF核心中的多重相关FK,postgresql,entity-framework,foreign-keys,entity-framework-core,ef-core-2.2,Postgresql,Entity Framework,Foreign Keys,Entity Framework Core,Ef Core 2.2,我有segmentation类,有一些价格范围,相关的office和route。我希望routeCountyMap表与route和county相关,但我只能为每个分段分配一次county。 例如,对于200-400分段,有A和B办公室,A办公室有E、F、g路线;如果X县有F路线,则无法进行2*00-400分段*。我的代码如下,如何安排 public class segment { [Key] public Guid segmentId { get; set; } publ
segmentation
类,有一些价格范围,相关的office
和route
。我希望routeCountyMap表与route和county相关,但我只能为每个分段分配一次county。
例如,对于200-400分段,有A和B办公室,A办公室有E、F、g路线;如果X县有F路线,则无法进行2*00-400分段*。我的代码如下,如何安排
public class segment
{
[Key]
public Guid segmentId { get; set; }
public string name { get; set; }
public Guid organisationId { get; set; }
}
public class office
{
[Key]
public Guid officeId { get; set; }
public string name { get; set; }
public Guid segmentId { get; set; }
public segment segment { get; set; }
}
public class route
{
[Key]
public Guid routeId { get; set; }
public string name { get; set; }
public Guid officeId { get; set; }
public office office { get; set; }
}
public class county
{
[Key]
public Guid countyId { get; set; }
public string name { get; set; }
public Guid cityId { get; set; }
}
public class routeCountyMap
{
public Guid routeCountyMapId { get; set; }
public Guid routeId { get; set; }
public Guid countyId { get; set; }
public route route { get; set; }
public county county { get; set; }
}
public class user
{
[Key]
public Guid userId { get; set; }
public string name { get; set; }
}
public class routeUserMap
{
[Key]
public Guid routeUserMapId { get; set; }
public Guid routeId { get; set; }
public Guid userId { get; set; }
public route route { get; set; }
public user user { get; set; }
}