2 tablespoons olive oil, plus more for coating the baking dish
1 large yellow onion, halved and thinly sliced
1 pound cremini mushrooms, stems removed and quartered
Kosher salt
Freshly ground black pepper
1 cup milk
2 large eggs
1 cup plus 2 tablespoons finely grated Pecorino Romano cheese, divided
4 cups cooked white or brown rice
2 (14-ounce) cans lentils, rinsed, or 2 1/2 cups cooked lentils
1/2 cup coarsely chopped fresh parsley leaves
Arrange a rack in the middle of the oven and heat to 375°F. Coat a 9x13-inch baking dish with olive oil.
Heat the 2 tablespoons of olive oil in a large frying pan over medium heat until shimmering. Add the onion and cook, stirring occasionally, until soft, golden, and caramelized, 8 to 10 minutes. Increase the heat to medium-high; add the mushrooms; season with salt and pepper; and cook, stirring occasionally, until softened and lightly browned, 4 to 5 minutes. Remove the pan from the heat.
Whisk together the milk, eggs, and 1 cup of grated cheese in a large bowl. Add the cooked rice, lentils, onion and mushroom mixture, and parsley; season with salt and pepper; and stir to combine. Transfer the mixture to the prepared baking dish and sprinkle with remaining 2 tablespoons grated cheese.
Cover the baking dish with aluminum foil and bake for 15 minutes. Remove the foil and bake until bubbling and golden-brown, 10 to 15 minutes more.