Reputation: 2706
In MVC6/EF7, should there be a difference in an order I use Include() to include navigation properties into a query?
This query works
var vt = await db.VehicleTypes
.Include(t => t.Photos)
.Include(t => t.VehicleModels)
.ThenInclude(m => m.Units)
.Include(t => t.Rates)
.ThenInclude(r => r.DailyPrice.Currency)
.ToListAsync()
But this query throws an exception at ToListAsync()
var vt = await db.VehicleTypes
.Include(t => t.Photos)
.Include(t => t.Rates)
.ThenInclude(r => r.DailyPrice.Currency)
.Include(t => t.VehicleModels)
.ThenInclude(m => m.Units)
.ToListAsync()
The error is
ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
I understand it's Beta, there may be bugs. In this case - is it a bug or a designed behavior?
Upvotes: 0
Views: 972
Reputation: 30405
Looks like a bug; the order shouldn't matter. Would you mind creating an issue?
Upvotes: 1