The French Revolution began in 1789, and at its onset the Margraviate of Baden was united under Charles Frederick, but it did not form a compact territory. Its total area was only about, consisting of a number of isolated districts lying on either bank of the upper Rhine. Charles Frederick endeavored to acquire the intervening stretches of land, so as to give territorial unity to his country. His opportunity to do so came during the French Revolutionary Wars. When war broke out between the French First Republic and the Habsburg Monarchy in 1792, the Margraviate of Baden fought for the House of Habsburg. However, their country was devastated as a result, and in 1796 the Margrave was compelled to pay an indemnity and to cede his territories on the left bank of the Rhine to the FrenchFirst Republic. Fortune, however, soon turned his way. With the German Mediatisation of 1803, and largely owing to the good offices of Alexander I of Russia, Charles Frederick received the Bishopric of Constance, part of the Electorate of the Palatinate, and other smaller districts, together with the prestige of being named a Prince-elector. In 1805 he changed sides and fought for Napoleon. As a result, later in 1805, when the Peace of Pressburg occurred, he obtained Breisgau and other territories at the expense of the Austrian Empire. In 1806, the Electorate of Baden signed the Rheinbundakte, joining the Confederation of the Rhine. Upon the dissolution of the Holy Roman Empire, Charles Frederick declared sovereignty and thus created the Grand Duchy of Baden, receiving other territorial additions as well. In 1806, Charles Frederick joined the Confederation of the Rhine, declared himself a sovereign prince, became a grand duke, and received additional territory. The Baden contingent continued to assist France, and by the Peace of Vienna in 1809, Charles Frederick was rewarded with accessions of territory at the expense of the Kingdom of Württemberg. Having quadrupled the area of Baden, Charles Frederick died in June 1811, and was succeeded by his grandson, Charles, Grand Duke of Baden, who was married to Stéphanie de Beauharnais, a cousin of Empress Josephine's first husband who had been adopted by Napoleon I.