How to specify two navigation properties from entity X to the same target entity, Y?

前端 未结 2 1525
青春惊慌失措
青春惊慌失措 2021-01-26 06:09

Consider that I have an Instructor class:

public class Instructor
{
    public InstructorTypesEnum Type { get; set; }

    public virtual ICollectio         


        
2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-26 06:50

    You can use the InversePropertyAttribute

    On your model, I think it would be (not verified):

    public class Instructor
    {
      public InstructorTypesEnum Type { get; set; }
    
      [InverseProperty("Instructors")]
      public virtual ICollection Courses { get; set; }
    
      [InverseProperty("Coinstructors")]
      public virtual ICollection CoInstructingCourses { get; set; }
    }
    

提交回复
热议问题