asp.net-mvc-2 - EF4 EntityException - 底层提供者在打开时失败

标签 asp.net-mvc-2 exception entity-framework-4

好的,这是一个新的。我正在尝试调试我的项目,我在过去做过很多次,现在我在我的一个存储库中遇到了这个异常。我以前没见过。我已经好几天没碰我的 repo 协议(protocol)了,我的连接字符串和以前一样。内部异常状态:

{"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"}

它阻塞的代码是:

public class HGArticleRepository : IArticleRepository
{
    private HGEntities _siteDB = new HGEntities();

    public List<Article> Articles
    {
        get { return _siteDB.Articles.ToList(); } // <-- this is the line
    }

    // more repo code
}

再一次,就像我说的,我以前从未遇到过这种异常,而且我已经好几天没有碰过我的域代码了。

最佳答案

这个错误通常意味着:

  1. 连接字符串指向不存在的 SQL Server。
  2. 连接字符串指向已关闭的 SQL Server。或者还没有开始。
  3. 命名管道传输在 SQL Server 设置中被禁用。

仔细一一检查。在你的情况下,我猜它是 2。

关于asp.net-mvc-2 - EF4 EntityException - 底层提供者在打开时失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5798047/

相关文章:

asp.net-mvc-2 - 未生成区域中的 T4MVC MVC2 View

c++ - 在标准 C++11 中获取剩余的可用内存?

.net - EF 等效于 SqlCommand.ExecuteNonQuery 影响的行

c# - Entity Framework : Unable to create a constant value of type 'System.Collections.Generic.IList` 1'

asp.net-mvc-2 - 无需编写 Controller 的简单 ASP.NET MVC View

asp.net - 在 asp.net MVC2 中的每个 Web 请求上创建的 nhibernate session

java - 为什么调用另一个抛出 RuntimeException 的方法需要 return 语句?

c# - 是否有可能使用 Entity Framework 4,让主键在对象上的名称与在表中的名称不同?

asp.net-mvc - 未创建 ASP.NET MVC 2 客户端验证规则

ios - 由CONTAINS谓词引起的异常