The building itself was never completed according to its original design. As mentioned earlier, by 1792 both the Patriarchate and the Seminary were located at Ajuda; but with the royal family living elsewhere, the working relationship between the Patriarchate and the royal family is unclear. Nevertheless, music continued to be written by members of the teaching staff for court events, and the Seminary continued its role with Seminarists and external students as before. Portugal's monarchy was driven into exile in Brazil by the French invasion which began early in 1807 and climaxed with the fall of Lisbon in November of that same year. On 29 November, a few days before the French troops marched into the capital, the royal family together with around 15,000 other Portuguese set sail for Brazil. This was a major blow for the Seminary and between then and 1815 it took no enrolments. France's repeated invasion of Portugal, three in all, came to a final end with their defeat in 1811 when combined British and Portuguese forces were able to drive the French army across the border into Spain where the war continued until 1814. The following year, João, still Prince Regent (because his mother Maria I was alive), and still living in Brazil, had the Seminary revived. It took in its first new students in 1816. Even after France's withdrawal from Portugal, the royal court remained in Brazil. Maria I died on 20 March 1816 and her son succeeded her as João VI, king of the United Kingdom of Portugal, Brazil and the Algarves, a structure he had established the year before in which Brazil and Portugal were of equal status. The royal family's long absence from Portugal created a climate of civil and political unrest, growing dissatisfaction with the model of monarchy and an urge for social reform. Support increased in many Portuguese cities and towns, and a climax came in 1820 when a military insurrection occurred in Porto. In response, João VI was forced to return from Brazil, leaving his son and heir-apparent Pedro first as regent and then as its first emperor following the declaration of Brazil's independence from Portugal on 7 September 1822. But even before his arrival in Lisbon in 1821, new electoral laws had been introduced the previous year and the country's first election held in December 1820 had led to the establishment of the 110-member "Cortes Gerais e Extraordinárias da Nação Portuguesa" (General Extraordinary and Constituent Cortes of the Portuguese Nation).