Answer: Oxygen receives two electrons from magnesium.
Explanation:
An ionic bond is formed when an element completely transfers its valence electron to another element. The element which donates the electron is known as electropositive element and the element which accepts the electrons is known as electronegative element. This bond is formed between a metal and an non-metal.
Electronic configuration of magnesium:
Magnesium atom will loose two electrons to gain noble gas configuration and form magnesium cation with +2 charge.
Electronic configuration of oxygen:
Oxygen atom will gain two electrons to gain noble gas configuration and form oxide ion with -2 charge.
Thus
and
combine to form
.