Fix loading foreign key entities

If the parent entity had it's primary key defined in a base class the
child entity would not get loaded and would return null