1

I have a visual studio 2013 update 4. I have a solution that includes multiple projects (all C#).

example:

  • -MySolution
  •    -Webapi project ( references core project )
  •    -core project ( regular class library, contains nuget package for EntityFramework 6.1.2 )

If I build the solution and try to exec a webapi method it fails because EntityFramework.SqlServer.dll is not in the bin folder of the webapi project.

If however I build the core project alone, EntityFramework.SqlServer.dll is copied into the bin folder of the Webapi project and everything is fine.

Is there some bug or am I doing something wrong by building the solution and expecting the same result if I had built the projects in order?

It appears to be some Nuget oddity at first blush.

Thanks in advance for any help!

Brandon
  • 984
  • 1
  • 11
  • 26
  • Consider posting your build output information. – SidF Jan 15 '15 at 20:04
  • If you're referencing the .dll directly, right click on the .dll->properties->Copy Always – lcryder Jan 15 '15 at 20:05
  • I think you need to have a reference to the EF NuGet package from your webapi as well. – Marcel Gosselin Jan 15 '15 at 20:11
  • I may not be able to post build output due to business constraints. I don't see any option for Copy Always, only Copy Local and that wouldn't copy from core to webapi in any case I don't think. I don't think webapi should have a ref to EF, core is the dependency there, not EF. Thanks for all the suggestions. – Brandon Jan 15 '15 at 20:58
  • If the core project reference is a Project Reference, then WebApiProject will need to have an explicit dependency on EF 6.1.2. If you pull Core out and make its own nupkg, it will have a dependency on EF 6.1.2 which should get pulled in automatically when you `Install-Package -Id MyCore` – Eris Jan 15 '15 at 22:44
  • Related post - [EntityFramework.SqlServer.dll not is getting added to the published folder only when I publish in RELEASE mode](https://stackoverflow.com/q/25433298/465053) – RBT Jul 23 '21 at 11:11

1 Answers1

1

"When you don't use the referenced DLL in your code at all, it will ignore the CopyLocal and won't copy it to your output directory." says the following link:

How does visual studio determine what to copy to the output directory with multi-project solutions?

Facing same problem and keeping with this hint, I made a dummy invocation in my library that referenced EntityFramework.SqlServer.dll and the issue was resolved:

string result = System.Data.Entity.SqlServer.SqlFunctions.Char(65);

May be you should also give it a try.

Community
  • 1
  • 1
man.kar
  • 125
  • 2
  • 9
  • 1
    Note: The dummy invocation is just for the compiler, you don't need to actually invoke this code at run time – man.kar May 20 '15 at 13:11