Reputation: 2814
I have a DataAccess assembly refering to the SQL Server Compact dlls.
From my main app I just add a reference to DataAccess assembly. I'd like my main app not to have any reference to any dll referenced by DataAccess internally, specifically a reference to SQL Server Compact assemblies, so that if I change to another provider I don't have to change reference in the main project or update app.config
configuration.
By the way at runtime I get the following error:
No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'.
Make sure the provider is registered in the 'entityFramework' section of the application config file.
See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
If I directly add a reference to SQL Server Compact everything works fine but I don't think I should do that.
If I copy all dlls used by DataAccess into main app output folder everything works fine, but should't dlls be copied automatically?
What's the right way to handle this?
Upvotes: 2
Views: 604
Reputation: 6238
In your solution:
UPDATE
I was able to reproduce your problem. It seems to me that a reason behind it is that in DataAccess project you are not using directly classes from SQL Server Compact assembly. In this case a build engine tries to be smart and doesn't copy assemblies that ''are not used''. However, it takes into account only a source code and not a configuration. There is a great answer about this problem worth reading. The suggested solution is to add a dummy code that directly uses SQL Server Compact assembly. This code (placed somewhere in DataAccess project) should worke:
var t = typeof (System.Data.Entity.SqlServerCompact.SqlCeFunctions)
Upvotes: 1