New transaction is not allowed because there are other threads running in the session LINQ To Entity [duplicate]

The pp variable isn’t a collection of objects, it’s an enumerator that can return objects. While you use the enumerator, the source has to remain open.

Use the ToList method to realise the enumerator into a collection. That will read all items from the enumerator and close the connection to the source, so that you can use the connection for other things.

foreach (var p in pp.ToList())

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)