A quick benchmark (loading thousands of objects in object graphs) shows that there are no markable differences in load time when lazy loading and proxy generation are enabled or disabled.
However, when you know that you do eager loading (and probably use a short-lived context) I would always turn off lazy loading and proxy generation.
context.Configuration.LazyLoadingEnabled = false;
context.Configuration.ProxyCreationEnabled = false;
Even though it doesn't noticeably improve performance, at least it removes the risk of triggering a lazy load when the context is out of scope, or a lazy load cascade when objects get serialized.
In your case, when eager loading prevails, you could even make this the default, i.e. turn of these properties in the constructor your context class.
Note that you do gain performance when you fetch objects with AsNoTracking()
, which is good practice when you get objects for read-only purposes. This happens quite often: in disconnected settings, e.g. when objects get serialized into a web client, the upload is always read-only, even though the client may be able to modify the objects. The changes are dealt with in the post action.