Melt the butter in a large saucepan over medium heat. Add the diced onion and cook until soft and translucent — about 3 to 4 minutes. Stir in the minced garlic and cook for another 30 seconds, just until fragrant.
Sprinkle in the flour and whisk constantly for about a minute to create a light roux. Slowly pour in the milk, whisking as you go to keep it smooth. Let it simmer until it thickens slightly, about 3–5 minutes.
Once the sauce coats the back of a spoon, remove it from the heat and stir in the sour cream, 1½ cups of shredded cheddar, salt, pepper, paprika, and garlic powder.
In a large bowl, mix the thawed hashbrowns with the creamy sauce. Stir until every bit of potato is evenly coated.
Pour the mixture into a greased 9×13-inch baking dish and spread it evenly with a spatula.
If you love a crispy topping (and who doesn’t?), mix the crushed cornflakes or breadcrumbs with melted butter and sprinkle them evenly over the casserole. Then top it all with the remaining cheddar and Parmesan.
Bake at 375°F (190°C) for 40–45 minutes, or until the top is golden and bubbly around the edges.
Let it rest for about 10 minutes before serving.