Vitamin D does not cause magnesium deficiency, but it can expose a marginal status because magnesium is a co-factor in the reactions that activate vitamin D. In simple terms, if you don’t consume a lot of magnesium and therefore don’t have enough on board to activate vitamin D, you will start to use up your limited magnesium at a higher rate when you start taking vitamin D, which may lead to symptoms (e.g. muscle cramping). Your need for vitamins and minerals varies by age and sex. This chart here provides the values:
http://iom.nationalacademies.org/~/media/Files/Activity%20Files/Nutrition/DRIs/5_Summary%20Table%20Tables%201-4.pdf
It is recommended that for each of these vitamins and minerals you achieve the DRI through diet and where intake is low, supplement to fill the gap.
Also, Dr. Cannell formulated a 5,000 IU supplement with all of the necessary cofactors:
http://www.purityproducts.com/dr-cannells-advanced-d-products/dr-cannells-advanced-vitamin-d