手动添加对实体框架的引用

编程入门 行业动态 更新时间:2024-10-27 04:26:50
本文介绍了手动添加对实体框架的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在从事一个围绕EF的项目. 我将项目的核心层分为不同的项目.

不幸的是,由于我在项目中缺少对EntityFramework.SqlServer.dll的引用,所以我不断收到正在发生的错误.

将.dll文件添加到build文件夹可以解决此问题,但是我想通过代码中的"using"语句解决该问题,但是由于我在项目中缺少对Entity Framework的引用,因此无法做到这一点.

我想知道如何添加一个?

* PS如果我在添加引用"面板中为EntityFramework进行搜索,那么我不会选择EF.

**我总是可以用NuGet来安装它,但是那不是多余的,因为我已经安装了它吗?

解决方案

在DAL使用EF的N层解决方案中,我遇到了同样的问题.

我通过在Web项目中添加对EntityFramework.SqlServer.dll的引用来解决此问题.

在对话框中转到引用->添加引用-> ,选择 COM 并按浏览. 然后转到使用EF的项目,然后转到存储EF引用的项目bin文件夹. 选择 EntityFramework.SqlServer.dll 并将其添加.

然后右键单击新添加的引用-> 属性->选择 Copy Local 为true

I am working on a project that revolves around EF. I have the core layers of my project separated into different projects.

Unfortunately I constantly get errors that are happening because I am missing a reference to EntityFramework.SqlServer.dll in my project.

Adding the .dll file to my build folder fixes this issue, but I want to solve it by a "using" statement in my code, however I cannot do that as I am missing a reference to Entity Framework in my project.

I was wondering how do I add one?

*PS If I serach for EntityFramework in the "Add reference" panel, I don't get EF as an option.

**I could always install it with NuGet, but wouldn't that be redundant, since I already have it installed?

解决方案

I had the same issue on a N-tier solution where the DAL uses EF.

I solved it by adding a reference to the EntityFramework.SqlServer.dll in the web project.

Go to references --> Add Reference --> in the dialog, choose COM and press browse. Then go to your project which is using EF and go to the projects bin folder where the EF references are stored. Select the EntityFramework.SqlServer.dll and add it.

Then right click on the newly added reference --> Properties --> Select Copy Local to true

更多推荐

手动添加对实体框架的引用

本文发布于:2023-11-16 10:38:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1603531.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:实体   框架

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!