I have this query and I get the error in this function:
var accounts = from account in context.Accounts
from guranteer in account.Gurantors
As a side-note...this can also happen when there is a problem with (internal) data-mapping from SQL Objects.
For instance...
I created a SQL Scalar Function
that accidentally returned a VARCHAR
...and then...used it to generate a column in a VIEW
. The VIEW
was correctly mapped in the DbContext
...so Linq was calling it just fine. However, the Entity expected DateTime? and the VIEW
was returning String.
Which ODDLY throws...
"There is already an open DataReader associated with this Command which must be closed first"
It was hard to figure out...but after I corrected the return parameters...all was well