views:

33

answers:

0

Let's say I have a Users table and a UserDetails table related with identifying relationship ( UserId is a PK of Users and PFK of UserDetails).

What I've noticed is that when I'm querying Users entity, EF generates SQL with a clause:

Users left outer join UserDetails

which doesn't really make sense, since only Users columns are selected.

If this behaviour is documented somewhere I couldn't find it. It resembles polymorphic query for fetching whole type hierarchy when Table per Type inheritance is defined, but there's no inheritance at all in case of those tables, just the 1-1 identifying relationship.

By the way, I'm using non-standard provider (NPGSQL for Postgres), but as I've been told the behaviour occurs also on standard sql server provider, so it probablt happens in the EF core.

The query is simple as it gets:

User user = dbContext
             .Users
             .FirstOrDefault(u => (u.Login == login) && (u.StatusId == (int)UserStatus.ConfirmedEmail);

So, I'm relying only on User entity properties.