无法连接到本地数据库,文件未发现异常

本文关键字:文件 未发现 异常 数据库 连接 | 更新日期: 2023-09-27 18:03:58

这里是连接字符串

<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类,我可以连接到数据库

无法连接到本地数据库,文件未发现异常

可能是权限的问题。在身份验证部分中。如果您不能写入正确的连接字符串,您可以使用"工具"菜单项中的"连接到数据库"选项,如果"测试连接"正常,则复制连接字符串。