The formula of the hydrated salt is `MgCl_(2).6H_(2)O`. When heated, it gets hydrolysed to form MgO.
`MgCl_(2).6H_(2)O overset("Heat")(to) MgO + 2HCl + 5H_(2)O`
Therefore, the salt cannot be dehydrated by heating as such. The dehydration is done by passing HCl gas through the hydrated salt at about 650 K.
`MgCl_(2).6H_(2)O underset(650K)overset(HCl(g))(to) underset("Anhydrous")(MgCl_(2)) + 6H_(2)O`