Diffusion can generate much larger isotope fractionation than equilibrium isotope fractionation. Previous experimental studies on diffusive isotope fractionation have used diffusion couple experiments. Here, we report a study investigating diffusive Mg isotope fractionation in melts during mineral dissolution experiments in andesite, basalt, and Fe-free "basalt". The goal of the study is to (a) use mineral dissolution experiments to determine the empirical beta factor for diffusive isotope fractionation in melts, and (b) evaluate the variability of beta for diffusive Mg isotope fractionation because literature data showed a range of 0.045 to 0.10. We first derive the analytical solution for diffusive isotope fractionation in melts during mineral dissolution and examine the dependence of the interface isotope ratio on other parameters and the behavior of the isotope diffusion profile. We then report SIMS measurement of Mg isotope diffusion profiles during anorthite dissolution in basalt and olivine dissolution in andesite. Mg isotope diffusion profiles during anorthite dissolution are as expected and can be modeled well leading to beta Mg of 0.052 +/- 0.011 in a mid-ocean ridge basalt and 0.077 +/- 0.012 in an FeO-free "basalt", but the delta 26Mg profile during an olivine dissolution experiment in andesite is not as expected. We suspected that the latter was due to significant matrix effect on analyzed delta 26Mg values because of the large compositional variation along the diffusion profile. To examine this effect, glass standards with compositions similar to those in points along the diffusion profile were synthesized using MgO powders from the same bottle (meaning the same Mg isotope ratio). The matrix effect is indeed significant. After correcting for it, the diffusion profile of Mg isotope ratios is as expected and can be modeled well with beta Mg of 0.074 +/- 0.002. Combining the new result with previous results, the beta Mg value for diffusive isotope fractionation in andesite to basalt is 0.052 to 0.077 based on anorthite and olivine dissolution experiments, which lies within literature values. The range of beta Mg values can be reconciled using diffusion mechanisms inferred from multicomponent diffusion studies. The method developed in this study can be applied to investigate diffusive isotope fractionation in other mineral dissolution studies. Furthermore, diffusive isotope fractionation in melt during rapid phenocryst growth in natural basalt may also be measurable under favorable conditions, potentially opening a new perspective in understanding crystal growth and fractionation.