Pre-heat the oven to 350°F.
Layer the first 6 ingredients in a greased 13 inch x 9-inch baking dish.
In a large bowl, whisk flour, eggs and milk until smooth.
Add corn, salt and pepper; mix well.
Pour over top of casserole; let stand 15 minutes.
Dot with butter and sprinkle with pecans.
Cover and place in the pre-heated oven; bake 35 minutes.
Remove from the oven; uncover and bake 30 to 35 minutes more or until a knife inserted in the center comes out clean.