Fix primary key discovery