There are ionic bonds in magnesium salt.
Magnesium salt in a solid form doesn’t conduct electricity because the ions can’t move freely - they are bound in a lattice by electrostatic forces. However, the salt dissolves in water, so the ions can move freely in the solution and carry charge.