Preheat the oven to 375°F (190°C). Lightly grease a 9x13-inch baking dish.
This helps the first layer release cleanly and prevents sticking.
Make the chicken filling. Heat olive oil in a skillet over medium. Sauté the diced onion for 3–4 minutes until softened. Add garlic and cook 30 seconds.
Stir in shredded chicken, green chiles, cumin, chili powder, salt, and pepper. If using black beans and corn, add them now. Warm through for 2–3 minutes.
Warm the tortillas. Briefly warm corn tortillas in the microwave wrapped in a damp paper towel, or heat them in a dry skillet.
Soft tortillas are less likely to crack and layer more neatly.
Layer the casserole. Spread 1/2 cup enchilada sauce on the bottom of the baking dish. Add a single layer of tortillas (tear a few to cover gaps). Spoon a third of the chicken mixture on top, pour about 3/4 cup sauce over it, then sprinkle a generous layer of cheese.
Repeat the layers. Do two more rounds of tortillas, chicken, sauce, and cheese.
Finish with a final layer of tortillas, the remaining sauce, and the rest of the cheese. You should have 3 layers of filling with tortillas on the bottom and top.
Bake until bubbly. Cover with foil and bake for 20 minutes. Remove the foil and bake another 10–15 minutes, until the cheese is melted and lightly browned around the edges.
Rest before slicing. Let the casserole rest for 10 minutes.
This helps it set, so slices hold together.
Finish and serve. Top with chopped cilantro, and serve with sour cream and lime wedges if you like. A crisp side salad or simple rice rounds it out.