Melt the butter in a medium skillet and saute on medium-low the onion with the salt and sugar until caramelized. It could take up to 20 min.
Butter an 8x11" casserole and set aside.
Whisk together the eggs with the water and stir in the flour and salt until combined.
Bring a pot of salted water to boil.
Run the dough through a spaetzle maker in batches, into the boiling water. Boil for 2 min. or until it floats. Remove spaetzle with a slotted spoon to a bowl and continue cooking until all are done.
Preheat oven to 350F.
Place half the spaetzle in the prepared casserole with half the cheese and onions and then repeat. Bake for 20 min. covered. Uncover and bake for 10 more min.