Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 实体框架,提供程序无法打开_C#_Entity Framework_Connection String - Fatal编程技术网

C# 实体框架,提供程序无法打开

C# 实体框架,提供程序无法打开,c#,entity-framework,connection-string,C#,Entity Framework,Connection String,我得到了这个错误: -InnerException {"Connection Timeout Expired. The timeout period elapsed during the post-login phase. The connection could have timed out while waiting for server to complete the login process and respond; Or it could have timed out while

我得到了这个错误:

-InnerException {"Connection Timeout Expired.  The timeout period elapsed during the post-login phase.  The connection could have timed out while waiting for server to complete the login process and respond; Or it could have timed out while attempting to create multiple active connections.  The duration spent while attempting to connect to this server was - [Pre-Login] initialization=86; handshake=2368; [Login] initialization=0; authentication=0; [Post-Login] complete=12018; "}  System.Exception {System.Data.SqlClient.SqlException}
由此:

       DataSourceContext Context = new DataSourceContext();
        var Booklist = Context.Booklists.ToList();
        Context.Dispose();
        Parallel.ForEach(Booklist, currentBook =>
        {
            switch (currentBook.FKcatalogNum)
            {
                case 0:
                    {
                       ...

                        finally
                        {

                                currentBook.BookDetails = Models.DBBookSourceInitializer.GetBookReaderNet(currentBook.Link);
                                try
                                {
                                    context.Booklists.AddOrUpdate(currentBook);
                                    context.SaveChanges();
                                }
                                catch (Exception e)
                                {
                                    ...

                                    context.Booklists.AddOrUpdate(currentBook);
                                    context.SaveChanges();

                            }
                            context.Dispose();
                        }
                        break;
我试图从数据库中获取所有书名,并添加有关其摘要、章节、页数等的详细信息。但我不断收到连接错误。有数千本书,在处理了一定数量的内容后,它给了我这个错误。从最后一本书的主键判断,它是1180,这意味着1180本书很好,然后突然发生了这种情况。 有人能告诉我我做错了什么,或者我应该改变什么吗。
谢谢你的帮助

你为什么要在使用前处理上下文?我没有?“…”表示我使用的一些代码,在我处理它之前,我正在try-catch块中使用它们?用一段短得多的代码复制这个错误,然后发布那个错误,而不是长版本。