好吧,我有两个项目:
我在 Blog.Core 中安装了EF。然后在博客中添加对 Blog.Core 的引用。我在 Blog.Core 中指定了我的连接字符串,因为这是我的DAL。现在,当我运行项目时,我收到以下错误:
An exception of type 'System.Data.SqlClient.SqlException' occurred in EntityFramework.dll but was not handled in user code
Additional information: 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)
我删除了连接字符串 Blog.Core 并将其放在博客项目中,并且它可以正常工作。这是为什么?这不会破坏体系结构,因为客户端有数据库连接字符串吗?我的意思是不正确,只有 DAL 应该负责连接字符串和数据库操作。为什么我的第一个(并且,根据我,更合乎逻辑)解决方案不起作用?