ProxyCreationEnable and performance issues in EntityFramework

In fall 2018, a co-worker and I ran into an issue with a StackOverflowException when a repository method returned a larger-than-usual amount of data. We tried a number of different things, but nothing really worked 100% of the time until we turned off ProxyCreationEnable in the context.

ContextOptions.ProxyCreationEnable = false;

Ultimately, this resolved the issue and still returned the data needed on the client side.

There are some things to consider if you try this. You may need to use eager loading, for example, instead of lazy loading.

StackOverflow – downsides to turning off proxycreationenable

White Paper discussing performance issues and advice

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.