Connection was not closed error while using entity framework within transaction scope having async/await
-
-
I got the following error "The connection was not closed. The connection's current state is connecting entity framework" while implementing Async/Await functionality in single transaction scope. Please provide the suggestions to resolve the issue.
We cannot see your screen. We cannot access your computer. And we cannot read your mind. If you want us to help you fix your code, then you need to show us your code.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
I got the following error "The connection was not closed. The connection's current state is connecting entity framework" while implementing Async/Await functionality in single transaction scope. Please provide the suggestions to resolve the issue.
Try below solution:
Quote:
For anyone still having this problem, look check this link: How to: Manually Open the Connection from the Object Context[^] The problem is the entity framework automatically opens and closes a connection with each call to the database, thus when using a transaction, you are attempting to spread a transaction out over multiple connections which elevates to MSDTC. Open the connection manually and close it when you are done. Then the framework will use only one connection for all your calls. Again, check the link for the details.
Source: EF4 - EntityException: The connection's current state is connecting.[^]
-
I got the following error "The connection was not closed. The connection's current state is connecting entity framework" while implementing Async/Await functionality in single transaction scope. Please provide the suggestions to resolve the issue.
Follow these instructions: EF4 - EntityException: The connection's current state is connecting.[^]