Code First and EF 5.0 not loading navigation properties

前端 未结 4 960
悲&欢浪女
悲&欢浪女 2021-01-14 13:39

I am trying to load a navigation property through Code First and EF 5.0 The child object is loading as null. below is the code.

  [Table(\"ls_roles\")]
    p         


        
4条回答
  •  猫巷女王i
    2021-01-14 14:28

    Your Role class does not need to use the ForeignKey attribute at all on the Employees collection. EF will automatically know to do the mapping based off of the ScheduleEmployee object and its use of the ForeignKey attribute.

提交回复
热议问题