Magnesium (Mg) has an atomic number of 12. Its electronic configuration is 2, 8, 2. Magnesium needs to lose two electrons to achieve a stable noble gas configuration. When magnesium loses two electrons, it forms a cation \( {Mg}^{2+} \):
\[
{Mg} \rightarrow {Mg}^{2+} + 2e^-
\]
Chlorine (Cl) has an atomic number of 17, and its electronic configuration is 2, 8, 7. Chlorine needs one electron to achieve a stable noble gas configuration. When chlorine gains one electron, it forms an anion \( {Cl}^- \):
\[
{Cl} + e^- \rightarrow {Cl}^-
\]
Two chlorine atoms are required to balance the charge of one magnesium cation. The ionic equation is:
\[
{Mg}^{2+} + 2{Cl}^- \rightarrow {MgCl}_2
\]
The cation formed is \( {Mg}^{2+} \) and the anion is \( {Cl}^- \).