I have one context created and then using Parallel.ForEach(…) I perform multiple EF queries simultaneously.
I have been encountering ‘The connection was not closed. The connection’s current state is connecting.’ and other exceptions along those lines.
I this due to the threaded nature of my application? Can you not use a single context simulataneously to simply read?
Object context is not a thread safe, so you probably you don’t want to use Parrallel.Foreach on multi threading scenarios
However, you can execute multiple queries on the same connection in parrallel with enabling MARS for example
however, you need to be aware of the performance.