Error while configuring multiple Navigation Properties to same table

前端 未结 1 1988
醉酒成梦
醉酒成梦 2021-01-19 10:09

I am having a weird issue with multiple navigation Properties to the same table.

My FuelBunkerType POCO class is configured like the following:

    p         


        
相关标签:
1条回答
  • 2021-01-19 10:33

    As you are configuring two one-to-may relationships between EventReport and FuelBunkerType and there is only one collection on the many side EF can't match the relationships. Depending on which relationship the collection property ActiveFuelTypes belongs to you can explicitly map it like this:

    modelBuilder.Entity<FuelBunkerQuantity>().
                 HasOptional(x => x.FuelBunkerType).
                 WithMany(e => e.ActiveFuelTypes).
                 HasForeignKey(x => x.IdFuelBunkerType);
    
    0 讨论(0)
提交回复
热议问题