Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EntityFrameworkDynamicProxies assembly load time

During startup of my application that uses the EntityFramework, I noticed that the assembly 'EntityFrameworkDynamicProxies-My.Entity.Namespace' is being loaded. And it actually takes some time before it gets loaded which doesn't matter that much in production, but during debugging, it's a bit annoying.

We have quite a lot of entity classes (around 100) which may explain the longer time needed for the generation of proxy classes during runtime. But we don't use the proxies at all, we have them disabled in configuration of the context (Configuration.ProxyCreationEnabled = false). So why is the dynamic proxy assembly generated and loaded if we don't use the proxies? And is there any way how to completely turn it off and therefore speed up the startup?

like image 274
siroky Avatar asked Feb 04 '14 20:02

siroky


1 Answers

I don't believe there's a way to get around that startup time when using Entity Framework, per se. What you could consider would be refactoring your context into smaller and more focused context. This strategy is known as "bounded contexts". Julie Lerman also has a good article on the subject.

The basic idea here is that within the scope of work a given EF context instance may need to perform, you will not need all entities that are part of your universal model. Structuring your EF contexts in this way will require less work of each one, so your first-run loading time should be greatly reduced.

like image 197
Yuck Avatar answered Nov 17 '22 23:11

Yuck