zoukankan      html  css  js  c++  java
  • Windows Service 项目中 Entity Framework 无法加载的问题

    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是不会一起产生的。

  • 相关阅读:
    [MS POST]Visual Studio Tips and Tricks
    Mono
    网络编程 socket编程
    Project Properties
    Review Error Handling
    [ILDASM Boxing]从进一步了解Struct和Class的不同学到的
    Steps to Bind VS solution to Source Control
    不已0开头的数字正则
    Jquery 解决移动端onclick事件300ms延迟问题
    毫秒转换日期
  • 原文地址:https://www.cnblogs.com/felixnet/p/5075935.html
Copyright © 2011-2022 走看看