I've created two entities which are related to each other by joining using three columns, both are views on the database. For the Travel
I have the Id
, FromCityId
and ToCityId
, for TravelCost
I have the TravelId
, FromCityId
and ToCityId
. The fluent mapping is as below
TravelEntityConfiguration
class:
HasMany(x => x.Amounts)
.WithRequired()
.HasForeignKey(x => new
{
x.TravelId,
x.FromCityId,
x.ToCityId
});
and for the travel cost its
TravelCostEntityConfiguration
HasRequired(x => x.Travel)
.WithMany()
.HasForeignKey(x => new
{
x.TravelId,
x.FromCityId,
x.ToCityId
});
When i query these entities and include the navigation property
context.Set<Table>().Include(x => x.TravelCost)....
For each result only the first of the child collection is loaded. I checked the query generated, even the query is correct it returns the full set with all the children and the join is correctly. What am i missing here. Need some help no clue for the moment. basically i suspect the mapping is not correct but didn't found out the problem yet.