【发布时间】:2017-01-01 12:41:16
【问题描述】:
这里是连接字符串
<add name="Tapo_ModelContainer" connectionString="metadata=res://*/filename.csdl|res://*/filename.ssdl|res://*/filename.msl;provider=System.Data.SqlClient;provider connection string='Data Source=(LocalDB)\MSSQLLocalDB;Initial Catalog=APTapo;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework'" providerName="System.Data.SqlClient" />
例外
System.Data.EntityException {"The underlying provider failed on Open."}
内部异常
"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)"
内部异常
"The system cannot find the file specified"
如果我使用普通的 SqlConnection 类,我可以连接到数据库。
【问题讨论】:
-
确保服务正在你的机器上运行.....
-
内部异常告诉你它无法连接到的问题:
(LocalDB)\MSSQLLocalDB看看:connectionstrings.com/sql-server-2012 我猜正确的数据源将是localhost或.\SqlExpress\并确保服务是运行
标签: c# sql-server app-config