You can even use EF core to execute a vanilla SQL statement, that would be my preferred option if the query and relationship are complex.