I could not stress enough how magnesium supplementation is an ESSENTIAL part of my approach to manage my epilepsy. Control of my horrible, terrifying and debilitating seizures I had suffered in the past has been tremendously liberating and magnesium supplementation has certainly played a crucial role in that success.

Magnesium is an abundant mineral in the body serving many biochemical functions and it is an essential electrolyte for all living organisms. It plays an important physiological role particularly in the brain, heart, and skeletal muscles. Normal dietary magnesium intake is estimated to be 300–350 mg per day for adults.
Magnesium supplementation has been shown to be beneficial in treatment of, among others, preeclampsia, migraine, depression, coronary artery disease, and asthma. http://physrev.physiology.org/content/95/1/1.abstract
In regards to epilepsy specifically it is worth noting this…
‘The concentrations of copper, magnesium, and zinc were all significantly altered in patients with epilepsy who received antiepileptic drugs compared with untreated patients with epilepsy. Designing treatments to selectively restore zinc levels may be a strategy for treating patients with epilepsy. It is still unclear whether these ions are causal to, or a cofactor in, the development of epilepsy. Knowledge of the effects of various antiepileptic drugs on trace element homeostasis could potentially be used to effectively guide appropriate therapeutic strategies in the future.’ http://nutritionreviews.oxfordjournals.org/content/73/11/760.abstract
I take magnesium chloride as a critical part of my seizure management approach. I take this orally mixed with water- 10 sprays at least 3-4 times a day. Each dose of 10 sprays = 150mg of Magnesium. I also have other natural treatment components complimenting this supplement nicely.
I choose magnesium chloride because for me personally it is the best form I have tried to control my seizure activity (which it does quite remarkably!), and it is convenient. I believe that the benefits of magnesium chloride are described quite nicely in the brilliant book ‘The Magnesium Miracle’ by Carolyn Dean M.D., N.D.

On magnesium chloride… ‘Some say it may be the best magnesium for ingestion. That’s because minerals need to be dissolved in gastric acid to go into solution. And, magnesium chloride has extra chloride molecules to produce hydrochloric acid in the stomach to enhance its absorption.’- personally I find that you have to build up to the dose I use to prevent any discomfort. 

It is also worth noting that our water supply in many countries is lacking in the magnesium it once had. There is a lot of calcium, but little magnesium in this water so I feel I benefit from adding additional magnesium to my filtered water. 
I have also recently tried magnesium citrate which I tolerate very well but it actually lowers my seizure threshold for some reason. This brand is excellent for general use. It can also be helpful if you have constipation, which some people experience on ketogenic diets. Find out which type of magnesium works for you and which one you tolerate best as an individual. I won’t be having this any more but you may like it. 

It is interesting how magnesium citrate doesn’t help at all with my seizure activity (and can even trigger seizures-possibly due to poor absorption) but magnesium chloride is brilliant and controls it completely. Potassium citrate helps with alkalising my urine and doesn’t interfere with my epilepsy but I need to make sure potassium, sodium, calcium and magnesium ratios are right for me. I’m sure it should be the same for others but they wouldn’t get instant feedback that someone with reflex epilepsy would get. Reflex epilepsy is when seizures only occur as triggers rather than being seemingly spontaneous or from a cause that cannot be changed. I found this useful but not sure how accurate the claims are:

I feel it is important to state that I eat a variety of insects that are reasonable sources of magnesium (particularly the exoskeleton), and occasionally I do eat macadamia nuts. Initially I struggle to tolerate nuts however since I have had significant healing of my scar tissue and I have improved my omega 3 to 6 ratio in my blood I find them much easier to tolerate. 
The same is true with foods containing salicylates which I find very interesting. I also consume a fair amount of oily fish and I can now add olive oil to it which is a nice feeling. I have read that olive oil can help to activate AMPK but perhaps not at the amounts we can consume without feeling nauseous. I do have other ways of managing this so I am not overly concerned at present in that respect. I can also tolerate avocados again and enjoy as an occasional snack. 
Magnesium supplementation is essential for most people these days and moreso for those with any type of epilepsy, a compromised blood brain barrier, or acquired brain injury.
We know that… ‘Magnesium is required for over 300 enzyme systems and is critical for many cellular functions including oxidative phosphorylation, glycolysis, DNA transcription and protein synthesis. Studies suggest that the modern Western diet and lifestyle may lead to magnesium deficiency, and this appears to be associated with a wide range of medical conditions. Magnesium deficiency decreases seizure thresholds in animal models of epilepsy and indeed low magnesium concentration in the perfusate is a common method of generating spontaneous epileptiform discharges from rat hippocampal slices.’
Magnesium is a potential modulator of seizure activity because of its ability to antagonize excitation through the N-methyl-d-aspartate receptor. http://www.sciencedirect.com/science/article/pii/S092012111200040X
Some studies have shown that people with epilepsy have lower magnesium than people without epilepsy. 
        There are case reports of seizures being controlled with magnesium supplementation in people with specific conditions, and recently in an open randomized trial, children with infantile spasms responded better to adrenocorticotropic hormone (ACTH) plus magnesium than to ACTH alone. http://www.sciencedirect.com/science/article/pii/S092012111200040X
        Oral Mg supplementation may prove to be a worthwhile adjunctive medication in treating drug intractable epilepsy. http://www.ncbi.nlm.nih.gov/pubmed/22547512
Seizures are clearly associated with ionic changes in the brain. I am rushed to write this post as I have a great deal on at the moment, but I will detail the main points with supportive research to explain the rationale behind my approach. Magnesium chloride replaces standard medication for me and I have found it to be incredibly effective alongside a strict ketogenic diet. Here are just some of the reasons why.
         Magnesium is a CNS depressant, with numerous functions intracellularly and extracellularly.
          Oral magnesium can act as a natural statin and reduce plasma blood glucose levels http://www.sciencedirect.com/science/article/pii/S1262363615000580
          Magnesium supplementation has been shown to raise seizure threshold in animal and human studies. http://onlinelibrary.wiley.com/doi/10.1002/jcph.626/abstract;jsessionid=96A16B1C52CB56D9E7C67CEEC60C561F.f04t03?userIsAuthenticated=false&deniedAccessCustomisedMessage=
        Similar to the ketogenic diet, magnesium has had nearly a century of clinical use to treat epilepsy. It been used as prophylaxis and treatment of seizures associated with eclampsia however because of the availability of well studied anticonvulsant drugs it has not been tested widely in the treatment of epileptic seizures. http://journals.cambridge.org/action/displayAbstract?fromPage=online&aid=9341631&fileId=S0317167100013457
          Eclampsia is defined as de novo seizure in a woman with the hypertensive complication of pregnancy known as preeclampsia (PE), and is a leading cause of maternal and fetal morbidity and mortality worldwide. http://scholarworks.uvm.edu/graddis/336/
        The pathogenesis of eclampsia during PE likely involves breakdown of the BBB and subsequent neuroinflammation, resulting in a state of greater seizure susceptibility that is ameliorated by MgSO4 treatment. This situation of a compromised blood brain barrier could be translated to brain cancer patients where more magnesium is required to combat likely deficiency. Brain cancer patients can have a ‘leaky brain’, particularly if they have had radiotherapy and chemotherapy.
        Magnesium sulfate is an evidence-based anticonvulsant drug used to prevent and control eclampsia. http://onlinelibrary.wiley.com/doi/10.1111/jog.12697/abstract?userIsAuthenticated=false&deniedAccessCustomisedMessage=
        Although magnesium sulfate is one of the most commonly used agents for seizure prophylaxis in preeclampsia, its efficacy relative to other anticonvulsants is incompletely investigated. http://www.sciencedirect.com/science/article/pii/0002937894900221
        Hypomagnesaemia is a recognized cause of generalized seizures. http://www.sciencedirect.com/science/article/pii/S1090379815001798
        Patients with hypomagnesemia suffer from a wide range of symptoms including muscle cramps, cardiac arrhythmias and epilepsy. http://www.jle.com/fr/revues/mrh/e-docs/the_art_of_magnesium_transport_305521/article.phtml
As we can see, magnesium sulphate is the most studied form of magnesium for the management of epilepsy:
        Magnesium sulfate infusions can be safely used in pediatric refractory status epilepticus. Magnesium sulfate can be considered in the management of children with febrile illness-related epilepsy syndrome. http://cno.sagepub.com/content/2/1/2329048X14550067.short
Compared to anti epileptic medication (AEDs)…

        Magnesium sulfate is a significantly more effective prophylactic agent than phenytoin for N-methyl-D-aspartate-induced seizures. http://www.sciencedirect.com/science/article/pii/0002937894900221