Halogens are non-metals and beryllium is also a non-metal. Since non-metals always form covalent bonds with each other due to almost similar I.P and E.N therefore,beryllium hallides are covalent .Magnesium is a metal and metals mostly form ionic bonds with non-metals due to vast difference in their I.P and E.N,therefore magnesium hallides are always ionic.
hope i helped u:)
plzz mark as best if helpful;)
1 1 1