Method 1
If you have an EDMX model, a partial class is created. Use that and in the OnContextCreated you can disable ProxyCreationEnabled
public partial class MyModelContainer
{
public void OnContextCreated()
{
this.Configuration.ContextOptions.ProxyCreationEnabled = false;
}
}
Method 2
Edit the model.tt file. Find the line containing something like this:
partial class <#=code.Escape(container)#> : DbContext
And add in
this.Configuration.ProxyCreationEnabled = false;
Method 3
If you are not using an EDMX file, do it in your context constructor: (assuming your context is called EspEntities)
public class EspEntities : DbContext
{
public EspEntities()
{
Configuration.ProxyCreationEnabled = false;
}
}