There is already an open DataReader associated with this Command which must be closed first

前端 未结 18 2504
孤街浪徒
孤街浪徒 2020-11-22 01:40

I have this query and I get the error in this function:

var accounts = from account in context.Accounts
               from guranteer in account.Gurantors
           


        
18条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 02:19

    In my case, I had to set the MultipleActiveResultSets to True in the connection string.
    Then it appeared another error (the real one) about not being able to run 2 (SQL) commands at the same time over the same data context! (EF Core, Code first)
    So the solution for me was to look for any other asynchronous command execution and turn them to synchronous, as I had just one DbContext for both commands.

    I hope it helps you

提交回复
热议问题