Yeah exactly... It wont help much but move the r = new Random(i) out to the initial declaration of r
seed it with DateTime.Now.Milliseconds if you really need a seed. Creating a new random every time isn't going to generate much more randomness
Another thing you could do, and again this won't solve too much but might help until the actual problem is resolved: Create a list outside of the loop that holds a number of Random word entries equal to the total number of iterations
so instead of generating a random word in the loop, they're pre-generated and just referenced as labr.FillerInfo = randomWords[i](for example)
Okay so you can instantiate that object outside the loop. Use EF's 'Attach' method
So create the whole thing, attach it (at which point EF will apply the ID) and then use that object's ID where you need it
so every non-database-related property for all those objects, EMRVisit, EMRAppts etc.. etc.. is created outside the loop 100k times. Then, inside the loop, you attach and get the ID then apply the ID to the existing objects where you need them
So, we already had moved the using statement inside of the for loop. That definitely helped the overall speed as time went on. Before it got bogged down a lot.
I have not rewritten it into 2 loops because there are more important things I'm working on and I think doing that right will take me a couple hours. However, I did tweak the appointments and lab results inner loop which appears to have helped some.