EF on the left joins the table every time I include

I have read several topics on how to enable all properties in EF Core. I have something like this:

_dbcontext.Transaction
.Include(x => x.Enterprise).ThenInclude(x => x.Manager)
.Include(x => x.Enterprise).ThenInclude(x=> x.Address)
.Include(x => x.Enterprise).ThenInclude(x=> x.Example)
...

      

Every time Entrepreneice, entityframework creates a new left join row. As a result, something like this:

SELECT TOP(1) x.Id, x.OtherColumnNames...
FROM Transaction as x
LEFT JOIN Enterprise AS e1 on x.EnterpriseId = e1.Id
LEFT JOIN Enterprise AS e2 on x.EnterpriseId = e2.Id
LEFT JOIN Manager AS m1 on e2.ManagerId = m1.Id
LEFT JOIN Enterprise AS e3 on x.EnterpriseId = e3.Id
LEFT JOIN Address AS a1 on e3.AddressId= a1.Id
LEFT JOIN Enterprise AS e4 on x.EnterpriseId = e4.Id
LEFT JOIN Example AS e1 on e4.ExampleId= e1.Id
...

      

Any suggestions on how I can make ef join my Enterprise table only once? Because this is not a good way to make database calls and slows down the whole query.

+3


source to share


1 answer


JOIN

duplication is a known issue in EF Core. Unfortunately, it hasn't been fixed in EF Core 1.1. According to this thread , the issue is assigned a value 2.0.0

without any estimated release date.



+2


source







All Articles