Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
541 views
in Technique[技术] by (71.8m points)

asp.net mvc - EntityFramework.SqlServer not deployed in web publish

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

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).

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

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.

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.

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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 MVC 3 Deployment package missing references

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;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...