Well, I have two projects:
- Blog.Core (a class library project for my entites as well as data access code)
- Blog (ASP.NET MVC Project)
I installed EF in Blog.Core. Then added reference to Blog.Core in Blog. I have specified my connection string in Blog.Core since this is my DAL. Now when I run the project I get the following error:
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)
I deleted the connection string form Blog.Core and placed it in Blog project, and it works. Why is that? Doesn't this break the architecture because client-side has the database connection string? I mean isn't that correct that only DAL should be responsible for connection strings and database operations. Why was my first (and, according to me, more logical) solution not working?