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

问题描述

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

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

假设你有一个解决方案有两个项目:一个是MVC3项目,另一个是数据访问的类库(Entity Framework模型类,数据上下文等)。

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 库。

MVC项目引用此类库 DAL DAL 库可能由应用程序之外的其他一些代码使用,因此将其与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 程序集复制到publish / 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?

推荐答案

附加的Google-fu似乎是解决办法是创建一些引用该缺失的程序集,即使代码未使用。

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.

我使用的解决方法是在数据上下文的构造函数中添加简单的测试行:

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