"And what if we want to stay and fight?"
-- Ernie Macmillan (DH31)
Ernie Macmillan is a Hufflepuff student in Harry‘s year.
Though sort of a pompous fellow, Ernie’s heart and loyalties are in the right place. Harry first met him in his second year, when Ernie took the lead among the Hufflepuffs in attempting to protect Muggle-born Justin Finch-Fletchley. Although at first he believed Harry to be the Heir of Slytherin, Ernie saw reason when Hermione was Petrified, and gave Harry a public apology, which was accepted (CS).
Ernie became a prefect in his fifth year, together with his close friend Hannah Abbott (OP10). At the beginning of that year, when the Daily Prophet‘s smear campaign was at its height and Umbridge was torturing Harry in nightly detentions, Ernie spoke up very loudly and publicly in support of Harry and Dumbledore in front of a grateful Harry (OP13). Ernie later suited action to words and joined Dumbledore’s Army (OP16), even joining the group that cursed Malfoy on the Hogwarts Express at the end of the year (OP38). He later fought in the Battle of Hogwarts, leading the crowd that wanted to stay at school and fight (DH31) and helping save Harry’s life with a Patronus (Ernie’s was probably the boar) (DH32).
Ernie was always one of the most studious Hufflepuffs. He was the only Hufflepuff in Harry’s N.E.W.T. level Potions class, implying that he got an O on the Potions O.W.L. (HBP9). This is due to Ernie studying eight hours a day for his O.W.L.s (OP31), a habit he frequently pointed out as he interrogated his classmates about their study habits.
Family
Ernie's family is pureblood for at least nine generations (CS11).
Other canon notes and references
Ernie has a birthday late in the school year (between April 21st and September 1st), as he was one of the only three out of twelve students left in Harry's Potions class when everyone who was seventeen did their Apparition tests (the other two being Harry and Draco) (HBP22). On this occasion, "determined to outshine Harry for once", he invents his own potion to try and impress Slughorn which "curdled and formed a kind of purple dumpling at the bottom of his cauldron" (HBP22).
Ernie's enthusiasm during Apparition lessons in sixth year provided a source of entertainment for some of the other students, particularly when he was concentrating so hard he "looked as though he was straining to lay a Quaffle-sized egg", and when he did "a kind of pirouetting leap into his hoop" and momentarily thought he had achieved Apparition (HBP18).
Like most of the Hufflepuffs, Ernie turned against Harry for a brief period in their fourth year when they thought he was stealing Cedric's glory by entering the Triwizard Tournament. He ignored Harry in Herbology but laughed at him when a Bouncing Bulb smacked him in the face (GF18), and was seen wearing one of Malfoy's "Support Cedric Diggory/Potter Stinks" badges (GF19).
Commentary
Etymology
"Earnest" = English for "serious;" also used to refer to something put up as a pledge of one's faith, such as 'earnest money.'