The idea of a benevolent Necromancer is one I came up with a while ago and have wanted to make into a D&D character at some point.
Desecration be damned, an undead army DEFENDING would be a superb tactic. The undead have no sense of morale, they'll keep fighting. The undead feel no pain, they'll keep fighting. Unless the invading army is also undead, has demons, or holy warriors, they'll be very easy to rout. And if it's the last two, the defenders will need all the help they can get.
And whether you believe in the afterlife or reincarnation is a moot point, because any way you look at it, the soul/conscious mind of the dead person has left the body entirely. Are they really going to care about that rotten husk? If I died - and if there were an afterlife - and I saw that those I'd left behind could use my corpse increase their odds of staying alive, I'd damn well want them to use it. When you get right down to it, it's no different than being an organ donor (which I am).
Now, you raise a fine point about not being able to fully trust the necromancer. For that reason, I'd require him to promise to send the corpses back to their graves once the invaders had been routed. I'd also make sure that he was stationed somewhere he could control his army, but that there were at least two combat-capable people I trusted very much to stay with him (one of them would probably be me), weapons free, in case he decided to break that promise.