Both Vitamin D3 and parathyroid hormone require magnesium to be activated. In addition, gut absorption and bone resorption of calcium use magnesium. Treatment with calcium should aim to restore calcium levels to within normal limits only. If too much calcium is given, then the animal's natural homeostatic mechanisms switch off and she remains dependant upon treatment. They also have a reduced appetite, so take in less calcium than their herd mates.
Prevention involves stimulation of the homeostatic mechanisms prior to calving.
This could theoretically be achieved with a relatively low calcium diet - but difficult in practice, as grass is a good source of calcium. Supplementary magnesium is a valuable tool. This can either be done by adding magnesium to the dry cow diet, or by supplying long fibre to increase magnesium uptake in the gut. It is important not to overfeed dry cows, and to maintain their appetite at calving.