Magnesium chloride is also ionic, but with a more complicated arrangement of the ions to allow for having twice as many chloride ions as magnesium ions. When magnesium ions are broken off the solid lattice and go into solution, there is enough attraction between the 2+ ions and the water molecules to get co-ordinate (dative covalent) bonds formed between the magnesium ions and lone pairs on surrounding water molecules.
MgCl2+6H2O⟶[Mg(H2O)6]2++2Cl−