首页 > Windows开发 > 详细

Windows Service 项目中 Entity Framework 无法加载的问题

时间:2015-12-25 16:30:23      阅读:840      评论:0      收藏:0      [点我收藏+]

Windows Service 项目引用了别的类库项目,别的项目用到了 Entity Framework(通过Nuget引入),但是我的 Windows Service 无法开启,于是我修改了 App.config,加入 EF 的配置信息后能开启,但是业务代码无法进入,通过日志发现错误:

System.InvalidOperationException: The Entity Framework provider type ‘System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer‘ registered in the application config file for the ADO.NET provider with invariant name ‘System.Data.SqlClient‘ could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.

意思就是 SqlProviderServices, EntityFramework.SqlServer 已经注册到 app.config,但是却不能正确加载,应该是某个DLL没有引入,直接对比Bin/Release目录,发现与其它正常项目相比少了个 EntityFramework.SqlServer.dll,将文件拷入,告成!

同理,如果我用的是 EF + MySql 数据库,则要保证 bin/Release 下有 MySql.Data.Entity.EF6.dll,生成项目和发布网站时,这两个DLL是不会一起产生的。

Windows Service 项目中 Entity Framework 无法加载的问题

原文:http://www.cnblogs.com/felixnet/p/5075935.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!