Probably after, but honestly, it doesn't matter
Yes, you can useSage Advice Compendium version 2.2 clarifies that the bonus attack action before orcomes after:
Does the “when” in the Eldritch Knight’s War Magic feature mean the bonus attack comes after you cast the cantrip, or can it come before? The bonus action comes after the cantrip, since using your action to cast a cantrip is what gives you the ability to make the weapon attack as a bonus action.
However, it says the cantriporder can easily be reversed:
a DM would break nothing in the system by allowing an Eldritch Knight to reverse the order of the cantrip and the weapon attack
This complies with RAI, according to J. That was explicitly clarifiedCrawford in the Rules answers: June 2016 -
Does the “when” in the Eldritch Knight’s War Magic feature mean the bonus attack comes after you cast the cantrip, or can it come before? The intent is that the bonus attack can come before or after the cantrip.
Generally you can choose the timings unless a description says otherwise:
You choose when to take a bonus action during your turn, unless the bonus action specifies when it must take place (PH, 189).