Biggest difference between race day and a regular long run is likely that on race day... you do a warm-up. So what is your warm-up routine the day of the race? How long before the start are you finishing your warm-up, do you take in any nutrition or fluids after your warm-up, what kind of stretching are you doing?
I did a bunch of things to get past my cramping, but the most important was probably to stop doing static stretching as part of my warmup. I realized that it wasn't even that conscious of a decision, I'd just stretch my calves on a curb, sit on the grass and stretch my hammies while watching others warmup, or grab a leg and stretch my quads at the start line. All out of nerves really, and just killing time until the start. Static stretching introduces small muscle tears ahead of a workout and can introduce risk of early fatigue, injury....and cramps. When I became more intentional about my entire warm-up routine - timing my warmup, doing dynamic stretches, intentional nutrition - I didn't get the muscle cramps.
Other things that I have done over the years that have helped as well: strength training (lunges, squats), core and glute work (Jay Johnson on youtube), running my training runs slower, doing some longer tempo work in my race flats, taking gels earlier in my race, and focus on hydrating well for the entire week ahead of the race. Good luck!