My belief, and I'm not sure where I read it, is that the Founders had a problem with military officers swearing allegiance to any individual.
Of course, the UCMJ has more than enough provisions to dissuade officers from butting heads with the President.
Like it or not, Duh-1 is the Commander in Chief, and he can demand their resignations any time. If they don't have the job, they can't in any way mitigate the effects of policy dictums.