使用一个依次使用实体框架的DLL [英] Using a DLL which in turn uses Entity Framework

查看:140
本文介绍了使用一个依次使用实体框架的DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在应用程序的服务库中使用了实体框架,但是不想在引用此DLL的任何应用程序中依赖于EF。我们遇到的问题是主要的应用程序有两个问题:

We are using Entity Framework in a service library for my application but don't want to have a dependency on EF in any application which makes reference to this DLL. The problem we have is the main application has two problems:


  1. 它没有对EntityFramework.dll的引用(我认为这是一个MSBuild问题?)

  2. 我需要将连接字符串放在主应用程序App.Config文件中

是否有任何解决方案或者我们必须接受使用此DLL的任何应用程序将需要NUGet安装EF?

Are there any solutions for this or do we have to just accept any application using this DLL will require a NUGet install of EF?

推荐答案

如果您的库需要访问Entity Framework中的代码,则需要EntityFramework.dll提供的Entity Framework代码。

If your library needs access to the code in the Entity Framework, it will need the code of the Entity Framework, provided by EntityFramework.dll.

如果另一个应用程序使用您的库,那么它也将需要EntityFramework dll中的代码。你不能运行你没有的代码。 (传递)依赖是不可避免的。

If another application makes use of your library, it will therefore also need the code in the EntityFramework dll. You can't run code you don't have. The (transitive) dependency is unavoidable.

这篇关于使用一个依次使用实体框架的DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆