Preheat your oven to 325°F (165°C) and prepare a 9x13-inch baking dish by greasing it.
In a small bowl, combine cornmeal and baking soda, mixing well and setting aside.
In a larger mixing bowl, beat the eggs until smooth. Add in chopped onions, whole kernel corn, cream-style corn, buttermilk, melted margarine, and diced green chiles. Stir until everything is well blended.
Fold in 2 cups of Cheddar cheese along with the cornmeal mixture, mixing gently until only small lumps of cornmeal are visible. Transfer the mixture into the greased baking dish.
Bake uncovered in the preheated oven for about 1 hour or until the casserole is set and golden on top. Once done, take it out and sprinkle the remaining 1 cup of Cheddar cheese over the top. Allow it to rest for 15 minutes before serving.