Sunday, September 23, 2012

Timeout issue with Entity Framework 4.0

When you are using a complex query via Entity Framework 4.0, you will be facing time out issue frequently.
Then you need to specify timeout of the query as below
  public TestEntities() : base("name=TestEntities", "TestEntities")
        {
            this.ContextOptions.LazyLoadingEnabled = true;
            //it's supposed to use the timeout of the "underlying provider"
            //because of that set the CommandTimeout property.
            //Each and every time when updating the model, need to add this property value in seconds.
            this.CommandTimeout = 180;
            OnContextCreated();
        }

No comments: