我的网络应用程序通过WCF调用一些方法,当我调用一个add方法时,该方法有一个foreach将数据添加到数据库。当它运行大约20次以上时,它会抛出异常,如下所示:
The underlying provider failed on Open.
at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)
at System.Data.EntityClient.EntityConnection.Open()
at System.Data.Objects.ObjectContext.EnsureConnection()
at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options)
at System.Data.Objects.ObjectContext.SaveChanges()
我使用MVC4和EF4。
foreach(){
CollDevValConRepository.Create(DB, quantity);
CollDevValConRepository.Save(DB);
}