Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. LINQ
  4. Connection was not closed error while using entity framework within transaction scope having async/await

Connection was not closed error while using entity framework within transaction scope having async/await

Scheduled Pinned Locked Moved LINQ
help
4 Posts 3 Posters 22 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    samkum36
    wrote on last edited by
    #1

    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.

    Richard DeemingR M 3 Replies Last reply
    0
    • S samkum36

      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.

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      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

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      1 Reply Last reply
      0
      • S samkum36

        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.

        M Offline
        M Offline
        Maciej Los
        wrote on last edited by
        #3

        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.[^]

        1 Reply Last reply
        0
        • S samkum36

          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.

          M Offline
          M Offline
          Maciej Los
          wrote on last edited by
          #4

          Follow these instructions: EF4 - EntityException: The connection's current state is connecting.[^]

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups