none
EntityFramework.SqlServer not deploying RRS feed

  • General discussion

  • I've seen various posts and workarounds regarding EF6 and EntityFramework.SqlServer not deploying to the bin. Here's one of a few variants: EntityFramework.SqlServer not deployed in web publish

    My question is if we have A with a dependency on B, and B has dependencies on EntityFramework and EntityFramework.SqlServer, why does the build only include EntityFramework in the final bin?

    And isn't this really a Microsoft issue about either deployment of references or the EF 6 nuget 6 package? As opposed to working around it with various techniques that some report are faulty in certain instances.

    • Changed type Fred BaoModerator Wednesday, March 26, 2014 1:46 AM The discussion type is more suitable for this case
    Tuesday, March 4, 2014 4:38 PM

All replies

  • Hello,

    >>why does the build only include EntityFramework in the final bin?

    When a type cannot be loaded for a DLL that is referenced in a project, it usually means that it has not been copied to the output bin/ directory. When we are not using a type from a referenced library, it will not be copied. That's expected behaviour. Usually, we just need to set the dlls Copy Local to be true, however, for the EntityFramework.SqlServer.dll it is not enough, a solution is to set a type reference as:

    public abstract class BaseDomainContext : DbContext
    
    {
    
      static BaseDomainContext()
    
      {
    
          var ensureDLLIsCopied = System.Data.Entity.SqlServer.SqlProviderServices.Instance;
    
      }
    
    }
    

    And for this behavior, I have submit a feedback to see whether it is designed or has others reasons:

    https://connect.microsoft.com/VisualStudio/feedback/details/828370/entityframework-sqlserver-dll-not-be-copied-to-porject-is-it-by-designed

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, March 5, 2014 3:21 AM
    Moderator
  • Hello,

    This behavior is by design.

    And explain from EF team:

    When a DAL project adds a NuGet reference to EF6, and the DAL project is then referenced by a consumer project, this does not automatically add the NuGet references to the consumer project. As such, the EntityFramework.dll and EntityFramework.SqlServer.dll assemblies are not copied by default to the final bin folder.

    The Entity Framework NuGet package must be installed to the consumer project (the final project) in order to make use of the DAL assembly. This should binplace the EF binaries in the final folder as expected.

    See the link in my first post.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, March 11, 2014 1:34 AM
    Moderator
  • I disagree - Microsoft did not answer the question about the Copy Local being set to true. I updated the comments in the comments in the link in your first post to clarify.
    • Edited by MikeOConnor Tuesday, March 11, 2014 11:37 AM
    Tuesday, March 11, 2014 11:37 AM
  • I've done some more research - other nuget packages that have multiple DLLs in them deploy correctly when used by a layer which is then used by the final consumer. AutoMapper is an example of this. 

    This really comes down to the EF team not setting up teh nuget package correctly.

    I would also like to further understand the comment "This behavior is by design." What design principle are you exactly referring to?

    Wednesday, March 19, 2014 3:37 PM
  • >> would also like to further understand the comment "This behavior is by design." What design principle are you exactly referring to?

    I am not know why it is designed by like this, but I do agree with that let the dll be copied to the final project automatically. And I think this feedback is a good, the best place for EF feedback is on Codeplex:

    http://entityframework.codeplex.com/discussions


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, March 20, 2014 9:39 AM
    Moderator