Entity Framework -- An unhandled exception of type 'System.StackOverflowException' occurred in System.Data.Entity.dll -- Why?
I am trying to use entity framework to make a questionairre. I cannot get the questionairre models to load at all -- each fails with a stackoverflowexception.
I have other models in other EDMX files, and they have worked fine so far.
QuestionEntities qc = new QuestionEntities();
System.Data.Objects.ObjectSet<FormView> qvs = qc.FormViews;
The overflow happens on the second line.
As far as I can tell, they are all set for lazy load, so it should not be attempting to load the entire DB. Just in case it has, I attempted to remove all recursive navigation properties, but it still fails.
The only similar entry I have found is C# - Entity Framework - An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll
Unfortunately, that one was only sol开发者_运维百科ved through repeatedly restarting the EDMX (which I have tried as well).
Any help would be appreciated, thanks
Please look into your generated code, you may have some recursive property definition which may cause the problem. Stack Overflow only occurs in recursive call that ends up in endless loop.
If you post your model and generated code, then it will be easy to find cause of problem.
We did have same problem when there were tables that were recursively included in search, for example consider a tree kind of structure like file system, where directory contains children which are directories, such navigation properties fail to include and results in stack overflow.
精彩评论