Melt the butter in a large pan. Add all the onions and season, then cover and cook gently for 35 minutes, stirring occasionally until the onions are very soft and starting to caramelise. Remove from the heat and allow to cool slightly.
Meanwhile, preheat the oven to 190 °C, gas mark 5.
Roll out the pastry on a lightly floured surface and use to line the 4-6 tart cases. Line the pastry with baking parchment and fill with baking beans.
Bake for 10 minutes then lift out the paper and beans and bake for a further 5 minutes until the pastry is golden brown.
Place the crème fraîche, eggs and nutmeg in a large bowl. Season with pepper and whisk together.
Stir in the caramelised onions and half the cheddar, and pour the mixture into the pastry cases. Scatter the remaining cheddar over the top.
Bake for 20-25 minutes until the surface is golden and the filling set, serve warm with a tomato salad.