本文介绍了EntityFramework.SqlServer没有部署的Web发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意到了这个奇怪的事情,也许这是一个错误,但我可能会丢失自己的东西。

Noticed this odd thing going on, perhaps it's a bug but I might be missing something myself.

假设你有一个包含两个项目的解决方案:一个是MVC3项目,另一个是一个类库,用于数据访问(实体框架模型类,数据上下文等等)

Suppose you have a solution with two projects: one is a MVC3 project, another is a class library for data access (Entity Framework model classes, data context and such).

该类库引用的EntityFramework (EF6)和 EntityFramework.SqlServer 库。

The class library references EntityFramework (EF6) and EntityFramework.SqlServer libraries.

和MVC的项目引用这个类库 DAL 。在 DAL 图书馆可以通过一些其他的code使用的应用程序之外,因此,从web项目分离了。

And the MVC project references this class library DAL. The DAL library may be used by some other code outside of the application, hence to decouple it from the web project.

总之,似乎在发布MVC3项目,过程失误复制 EntityFramework.SqlServer 组件发布/ bin目录。然而,它的确实发布基地的EntityFramework DLL与其他库和类库本身一起。

Anyway, it appears that upon publishing the MVC3 project, the process misses copying the EntityFramework.SqlServer assembly to the publish/bin directory. However, it does publish base EntityFramework dll along with other libraries and the class library itself.

有没有办法让出版商出版所需的SqlServer司机呢?

Is there a way to get the publisher to publish the required SqlServer driver as well?

推荐答案

好吧,所以一些附加的谷歌福后,会出现一个解决办法是建立一些参考失踪组装,即使code是未使用

Alright, so after some additional Google-fu it appears that a workaround is to create some reference to that missing assembly, even if the code is unused.

.NET

和我使用的解决办法是在数据方面的构造函数添加简单的测试线:

And the workaround I used is add simple test line in the constructor of the data context:

bool instanceExists = System.Data.Entity.SqlServer.SqlProviderServices.Instance != null;

这篇关于EntityFramework.SqlServer没有部署的Web发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 09:29