Emperor Wei Mingdi 魏明帝 (r. 226－239 CE), personal name Cao Rui 曹叡, courtesy name Cao Yuanzhong 曹元仲, was the second emperor of the Cao-Wei dynasty 曹魏 (220-265). He was a son of Emperor Wen 魏文帝 (r. 220-226) and Lady Zhen 甄夫人. Cao Rui was very fond of learning as a young boy and was deeply loved by his grandfather, the warlord Cao Cao 曹操. With the age of 15 sui he was enfeoffed as Marquis of Wude 武德侯, and in 220, when his father proclaimed himself emperor, as Prince of Pingyuan 平原王. His mother lost the favour of Emperor Wen, was slandered and forced to commit cuicide. Cao Rui thereupon refused to appear at the court and withdrew to the inner chambers of the palace where he dedicated himself to the study of literature. He was appointed heir apparent in 226, when his father was on the sickbed and going to die. Not before long Cao Rui became emperor. He venerated his mother posthumously as Empress Wenzhao 文昭皇后 and took Lady Mao 毛氏 to his own empress. During his reign the Counsellor-in-chief of the empire of Shu 蜀漢 (221-263), Zhuge Liang 諸葛亮, several times undertook military campaigns against Wei. Cao Rui sent out general Sima Yi 司馬懿 who was able to fend off the troops of Shu. This victory deeply strengthened his position, so that the Sima family became more and more powerful. In 228 Chen Qun 陳群 and Liu Shao 劉邵 replaced the old law codex of the Han dynasty 漢 (206 BCE-220 CE) by a new code, the Weilü 魏律 in 180 chapters. Emperor Ming had built a large palace garden, the Zhaoyang Hall of the Highest Extreme 昭陽太極殿, and had cast a series of bronze figures to stand in the front of the palace. He also spent a lot of money for presents to his officials, favourites and the princes, so that the state treasury was soon depleted. The ministers also remonstrated against his boundless recruitment of beautiful girls into the harem.
Emperor Ming himself had nevertheless no son, so that he appointed his foster-son Cao Fang 曹芳 heir apparent in 239. On his deathbed he entrusted the government to Cao Shuang 曹爽 and Sima Yi. He is buried in the tomb mound Gaoping 高平陵.