fharreau
fharreau

Reputation: 2347

How references are copied to the build folder?

I have a project A that references a project B. The project B has a reference to the EntityFramework nuget package (6.1.3). This package installs two dll : EntityFramework and EntityFrameork.SqlServer. There are no reference to EntityFramework from the project A.

When I build the project A, in the bin folder, there are the project B dll and the EntityFramework dll. But there is not the EntityFramework.SqlServer dll. And because of that, my project does not run well.

Why some of the project B dependencies are copied to the main project build folder but not all the dependencies ? (Both has the "copy local" properties set on true)

Sorry for my English, I am not a native speaker.

Upvotes: 0

Views: 101

Answers (1)

Taher  Rahgooy
Taher Rahgooy

Reputation: 6696

It is because there is no code in your projects that used EntityFrameork.SqlServer, so VS thinks there is no dependency and does not copy it. I use this workaround:

public class MyContext : DbContext
{
    //workaround to force sqlserver dll to copy
    private static SqlProviderServices instance = SqlProviderServices.Instance;
}

You can also add a reference to EntityFrameork.SqlServer from A project and set CopyLocal true for it.

Upvotes: 3

Related Questions