Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

Set database timeout in Entity Framework

public class MyDatabase : DbContext
{
    public MyDatabase ()
        : base(ContextHelper.CreateConnection("Connection string"), true)
    {
        ((IObjectContextAdapter)this).ObjectContext.CommandTimeout = 180;
    }
}

<connectionStrings>

<add name="AdventureWorksEntities"
connectionString="metadata=.AdventureWorks.csdl|.AdventureWorks.ssdl|.AdventureWorks.msl;
provider=System.Data.SqlClient;provider connection string='Data Source=localhost;
Initial Catalog=AdventureWorks;Integrated Security=True;Connection Timeout=60;
multipleactiveresultsets=true'" providerName="System.Data.EntityClient" />

</connectionStrings>
Source by entityframework.net #
 
PREVIOUS NEXT
Tagged: #Set #database #timeout #Entity #Framework
ADD COMMENT
Topic
Name
2+4 =