Why do I have to reference EF in my UI project?

后端 未结 5 1900
生来不讨喜
生来不讨喜 2020-12-17 18:16

Isn\'t there a more graceful way to have Entity Framework deployed with your UI project (specifically the sql server driver for EF: EntityFramework.SqlServer.dll) deployed w

5条回答
  •  北海茫月
    2020-12-17 19:16

    Explanation of issue(s) with EF configuration in multi project solution is here:
    EntityFramework.SqlServer (or other providers) not being copied locally
    It perfect explain me the reasons, but I found better workaround:
    I have a solution with UI project and DAL project.
    To not reference EF dll's in UI project I have done:.
    1) removed it from UI project references.
    2) add post-build event to UI project:

    if $(ConfigurationName) == Debug (
    copy $(SolutionDir)\DBWrapper\Bin\Debug\EntityFramework.SqlServer.dll $(SolutionDir)\IrregularVerbs\Bin\Debug\
    )
    else if $(ConfigurationName) == Release (
    copy $(SolutionDir)\DBWrapper\Bin\Release\EntityFramework.SqlServer.dll $(SolutionDir)\IrregularVerbs\Bin\Release\
    )
    

    the "(" char must be in the same line as "if" - in other way you get error:
    Error 2 The command "..." exited with code 255.

提交回复
热议问题