Pre-heat the oven to 190°. Roll the pastry out on a lightly floured surface to 5mm thickness and use it to line an 8 inch springform fluted tart tin. Prick the base all over and chill.
Melt the butter and olive oil in a large frying pan over a moderate heat and add the onions, sweating with a little salt until soft; 6-7 minutes, stirring occasionally. Reduce the heat and let the onions slowly caramelise, stirring occasionally.
Remove the pastry from the fridge as the onions caramelise and line it with nonstick baking paper and baking beads. Blind bake for 15 minutes until the edges just start to colour. Remove from the oven, discard the paper and baking beans, then return to the oven for 5 minutes to brown the base a little. Remove from the oven and brush all over with the small beaten egg to create a seal. Leave to cool on a wire rack.
Once the onions have caramelised and are golden brown in colour, remove from the heat and set to one side. Reduce the oven to 170°.
Whisk together the crème fraîche, whipping cream, Gruyère cheese, beaten medium eggs, egg yolk and seasoning until smooth. Spoon the onions and the pancetta into the base of the cooled pastry and arrange in an even layer. Pour the egg filling on top and return to the oven for 25-30 minutes until just set and golden brown on top.
Remove and allow to cool for a few minutes before turning out from the tin and garnishing with a sprig of thyme leaves. Serve hot or cold.
Haven't got time to make this from scratch?
Try our ready made version - Tesco Cheese and Onion Tart.
For top tips on protecting you and your family when preparing raw meat and poultry, visit Food Safety in the Home and view the full Food safety at home video.