Ephraim is synonymous with the House of Israel (10 tribes).
That should tell you something.
(Ezk 37:15) 6 Moreover, thou son of man, take thee one stick, and write upon it, For Judah, and for the children of Israel his companions: then take another stick, and write upon it, For Joseph, the stick of Ephraim and for all the house of Israel his companions:
Ephraim being called firstborn is not synonymous with Israel being called firstborn.
Ephraim is called firstborn because he had the rank of being above/exalted/higher in rank than the other tribes of the Northern Kingdom.
He certainly wasn't the 1st born in sequence.
David is called firstborn because he had the rank of being above/exalted/higher in rank than the other kings of all the other nations.
He certainly wasn't the 1st born in sequence.
Israel (all 12 tribes, sons of Jacob) is called firstborn because they had the rank of being above/exalted/higher in rank than the all the other kingdoms.
Jacob certainly wasn't the 1st born in sequence.
It's about rank, not sequence.