Re: Entitity Framework, problem with lazy loading
Posted by: Michel Lehon
Date: June 16, 2009 09:55AM

Well you seem to have hit the problem with the Entity Framework not supporting unsigned integers..

I had the same problem, and it went away when I changed all my keys to signed integers (I was lucky enough to start a new project).

However the luck was short lived, as using the .Load() method inside a foreach loop triggers an other exception stating that an other data reader is already open.
Indeed: one reader for the foreach loop... and one for the .Load

I did font this information on MSDN:
When you call the Load method during a foreach (C#) or For Each (Visual Basic) enumeration, Object Services tries to open a new data reader. This operation will fail unless you have enabled multiple active results sets by specifying multipleactiveresultsets=true in the connection string. For more information, see Using Multiple Active Result Sets (MARS) on MSDN. You can also load the result of the query into a List collection, which closes the data reader and enables you to enumerate over the collection to load referenced objects. (at 2/3 at the bottom).
MySQL Connector does not support MARS (In case you were wondering).

The only real work around I could find is using .Include to ask the entity Framework to preload the linked entities.

I hope this helps.


Options: ReplyQuote

Written By
Re: Entitity Framework, problem with lazy loading
June 16, 2009 09:55AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.