I wrote code by following an answer from SqlException from Entity Framework - New transaction is not allowed because there are other threads running in the session. However after 50,000 records I've got an OutofMemoryException and was able to solve it with the answer from another question, Entity framework large data set, out of memory exception.
My final solution solved both errors, and I was able to provide more details than existing answers, so I decided to add answers with my solution to both questions. I believed it would be useful for readers of both questions. I’ve added the full answer with code snippet to one of the questions and relatively short answer to the second question with reference to the snippet in the first question.
Thanks to Luke McGregor's answer I've implemented renewal of context for each batch. It described in my answer to SqlException from Entity Framework - New transaction is not allowed because there are other threads running in the session. It includes code snippet.
I decided not to duplicate the snippet (DRY principle) as it belongs to Stack Overflow, not to external site. However my short answer was deleted by reviewers as low quality (with different reasons: "This should be a comment, not an answer.", "This does not provide an answer to the question.", and even "Please don't add "thank you" as an answer.")
Was I wrong that didn’t duplicate the snippet (and make the answer complete), or just unlucky, that reviewers didn’t realised that the link refers to Stack Overflow?