c# - MVC4 网站仅适用于一台 PC,不适用于其他 PC,失败并显示 "SQL Network Interfaces, error: 26"

标签 c# sql-server asp.net-mvc entity-framework ef-code-first

下面的 MVC4 ef-codefirst 应用程序在我的电脑上运行良好,但在其他任何地方都运行良好。

两台计算机上都安装了 VS 2012 Ultimate 和 SQL Express。

两台计算机都使用此连接字符串:

<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-AppointmentMVC4-20130118154339;
Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-AppointmentMVC4-20130118154339.mdf"
providerName="System.Data.SqlClient" />

当尝试从开发计算机以外的计算机访问数据库时:

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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

工作机器有这个数据库连接: enter image description here

使用localDBsqlexpress 作为连接并不重要;让它成功很重要。

DbContext 类:

public class AppointmentContext : DbContext
{
    public DbSet<Appointment> Appointments { get; set; }
    public DbSet<User> Users { get; set; }
}

最佳答案

我认为 LocalDB 只支持通过命名管道协议(protocol)的本地连接。
http://www.sqlcoffee.com/SQLServer2012_0004.htm

关于c# - MVC4 网站仅适用于一台 PC,不适用于其他 PC,失败并显示 "SQL Network Interfaces, error: 26",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14469186/

相关文章:

sql - 如何在Sql Server 中获取最大值的多个字段?

jquery - 处理带有多条记录的 asp.net core 表单提交中的多选列表框值

c# - 为什么使用 SqlCommand 插入语句很慢?

Access 和 SQL Server 的 C# TableAdapter

asp.net-mvc - MVC中的执行流程

c# - 将现有程序集添加到 mvc 6 项目

c# - 统一 5 : access/modify AnimatorController from C# script in editor

c# - C# 中的可选数组参数

c# - 多态性不适用于 C# 中泛型类的调用

c# - 使用正则表达式分割