EntityFramework.sqlServer dll not found

本文关键字:found not dll sqlServer EntityFramework | 更新日期: 2023-09-27 18:34:45

我们有 ASP.NET 网站,它引用了引用EntityFramework dll的项目(dll(。我们添加了实体框架.dll并手动EntityFramework.SqlServer.dll对 bin 文件夹的引用(而不是通过 Nuget(。我们正使用八达通部署我们的网站。在部署时,我们在 bin 文件夹中没有 EntityFramework.SqlServer dll。我经历了各种答案,但无法得到。有人知道同样的答案吗?我尝试通过VS发布,并在bin文件夹中看到EF的SqlServer。令人惊讶的是,我们在 EF dll 版本的 web.config 中没有任何引用条目。

不确定添加他们中的一些人建议的以下代码 -

 var ensureDLLIsCopied = System.Data.Entity.SqlServer.SqlProviderServices.Instance;

错误信息-

ERROR occurred in LockAutomationNotification.NotifyEmail
System.Data.Entity.Core.MetadataException: Schema specified is not valid. Errors: 
OLIEDataModel.ssdl(2,2) : error 0152: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'. Make sure the provider is registered in the 'entityFramework' section of the application config file. See 

EntityFramework.sqlServer dll not found

您的第一个问题的答案在这里。它正在发生,因为EntityFramework.dll而不是您的项目代码在内部引用EntityFramework.SqlServer.dll

您收到的新错误是由于缺少配置。请在您网站的web.config中添加以下设置:

<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
<entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
</configuration>