1Preheat oven to 350 degrees F (175 degrees C). Grease a 9x13-inch casserole dish with cooking spray.
2Spread an even layer of mayonnaise on one side of each slice of bread. Place 6 slices of bread mayonnaise-side down in a single layer at the bottom of the casserole dish.
3Bake in the preheated oven until lightly toasted, about 5 minutes. Remove from oven and top each slice of bread with 1 slice of Cheddar cheese. Cover with 6 more slices of bread, mayonnaise-side up.
4Bake in the preheated oven until bread is lightly toasted, about 5 minutes.
5Sprinkle 1/4 of the shredded Cheddar cheese on top. Arrange slices of ham on top; cover with another 1/4 of the shredded Cheddar cheese. Repeat with bacon slices, covering with another 1/4 of the shredded Cheddar cheese. Arrange last 6 slices of bread, mayonnaise-side up, on top.
6Whisk eggs, milk, salt, and black pepper together in a large bowl. Pour evenly over bread in the casserole dish. Sprinkle remaining 1/4 cup shredded Cheddar cheese on top. Cover with aluminum foil.
7Bake in the preheated oven until set, about 30 minutes.
8Remove aluminum foil and continue baking until cheese is bubbly and golden, 5 to 10 minutes more.