Magnesium has a total of 12 electrons, so if we draw the electrons for Magnesium, you will have 3 shells. The first shell and second shell will be occupied by the maximum number of electrons. The third shell will occupied by the remaining 2. Therefore, Magnesium has 2 valence electrons.