Wednesday, March 19, 2014

Entity Framework: Change SQLServer Command timeout



By adding in a few code in the DBContect we can increase SQLServer Command timeout

 public class WeedingContext : DbContext
    {
        public WeedingContext()
            : base("WeddingDb")
        {
            // Get the ObjectContext related to this DbContext
            var objectContext = (this as IObjectContextAdapter).ObjectContext;

            // Sets the command timeout for all the commands
            objectContext.CommandTimeout = 180;
        }