ConnectionTimeout'u varsayılandan başka bir şeye ayarlamak istiyorum: 15 saniye. Ben EntityFramework kullanan bazı kod miras ve app.config şuna benzer:EntityFramework kullanırken ConnectionTimeout ayarı
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS; Integrated Security=True; ConnectionTimeout=30; MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
<parameters>
<parameter value="Data Source=.\SQLEXPRESS; Integrated Security=True; ConnectionTimeout=30; MultipleActiveResultSets=True" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
Ben İşlerin yürütülmesi için bir girişim sectino eklendi benim. Neler oluyor hep 15.
var adapter = (IObjectContextAdapter) this;
var objectContext = adapter.ObjectContext;
objectContext.CommandTimeout = CommandTimeoutSeconds;
int test = objectContext.Connection.ConnectionTimeout;
testinde olduğu: anlarım o bir kesme noktası ayarlama olmak Çalışmıyor mu? Birisi bana ConnectionTimeout'u nasıl ayarlayacağını söyleyebilir mi? Hem "ConnectionTimeout" hem de "Connection Timeout" ıı denedim. boşluk ya da alan yok.
Birisi bana yardımcı olabilir mi? Saçlarımı çekiyorum. Eminim bu basit bir çözüm! Dave
Ek bilgi. Yorum yanıt olarak, burada bu soruna neden oldu benim açımdan aptallıktı
public class SessionDataContext : DbContext
{
// Command timeout (seconds)
private const int CommandTimeoutSeconds = 30;
/// <summary>
/// Constructor that takes db name.
/// The connection string and db itself is configured in the this project's app.config file
/// </summary>
/// <param name="dbName"></param>
public SessionDataContext(string dbName) : base(dbName)
{
Database.SetInitializer(new SessionDataContextInitializer());
// Set timeout (based on code from http://stackoverflow.com/questions/6232633/entity-framework-timeouts)
var adapter = (IObjectContextAdapter) this;
var objectContext = adapter.ObjectContext;
objectContext.CommandTimeout = CommandTimeoutSeconds;
int test = objectContext.Connection.ConnectionTimeout;
}
/// <summary>
/// Session table's records
/// </summary>
public DbSet<Session> Sessions { get; set; }
/// <summary>
/// SessionType table's records
/// </summary>
public DbSet<SessionType> SessionTypes { get; set; }
}
DbContext türetilmiş sınıfınızı nasıl yaratıyorsunuz? Bağlantı dizesi adını oradan mı geçiyorsunuz? – Pawel
Merhaba Pawel, DbContext tahrikli sınıfı soruya koydum. Soruma baktığın için teşekkürler. – Dave
http://stackoverflow.com/questions/6232633/entity-framework-timeouts'a bir göz attınız mı? –