Start by making your crust—combine flour and salt in a bowl, then cut in the cold butter with a fork or pastry cutter until it looks like coarse breadcrumbs. Add just enough cold water (about 3-4 tablespoons) to bring it together into a shaggy dough. Press it into a 9-inch tart pan and prick the bottom with a fork. Chill while you prep your filling.
Heat your oven to 375°F and line your crust with parchment paper and pie weights (or dried beans work great). Bake for 12 minutes, then carefully remove the weights and parchment. You want it partially baked but not golden yet—that's the sweet spot.
While the crust bakes, heat olive oil in a skillet over medium heat and sauté your chopped onion until it's soft and just starting to turn golden, about 4 minutes. Add the minced garlic and cook for another 30 seconds until it smells amazing.
Toss in your asparagus pieces and cook for 3 minutes—you want them still pretty firm since they'll keep cooking in the oven. Season with salt and pepper, then spread this mixture evenly over your partially baked crust.
Whisk together the heavy cream, 2 eggs, most of the grated cheese (save some for the top), salt, and pepper in a bowl until smooth. Pour this custard mixture carefully over the asparagus, making sure it settles around all the pieces.
Sprinkle the reserved cheese on top and brush the edges of the crust with your beaten egg. This gives you that beautiful golden-brown finish that makes the whole thing look polished and fancy.
Bake for 28-32 minutes until the custard is set but still jiggles just slightly in the very center—don't overbake or it gets rubbery. Let it cool for 5 minutes before slicing so it holds together nicely.