No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'

异常描述:

System.Data.Entity.Core.MetadataException: Schema specified is not valid. Errors:
PaycenterModels.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 http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
在 System.Data.Entity.Core.Metadata.Edm.StoreItemCollection.Loader.ThrowOnNonWarningErrors()
在 System.Data.Entity.Core.Metadata.Edm.StoreItemCollection.Loader.LoadItems(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths)
在 System.Data.Entity.Core.Metadata.Edm.StoreItemCollection.Loader..ctor(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, Boolean throwOnError, IDbDependencyResolver resolver)
在 System.Data.Entity.Core.Metadata.Edm.StoreItemCollection.Init(IEnumerable`1 xmlReaders, IEnumerable`1 filePaths, Boolean throwOnError, IDbDependencyResolver resolver, DbProviderManifest& providerManifest, DbProviderFactory& providerFactory, String& providerInvariantName, String& providerManifestToken, Memoizer`2& cachedCTypeFunction)
在 System.Data.Entity.Core.Metadata.Edm.StoreItemCollection..ctor(IEnumerable`1 xmlReaders, IEnumerable`1 filePaths)
在 System.Data.Entity.Core.Metadata.Edm.MetadataCache.LoadStoreCollection(EdmItemCollection edmItemCollection, MetadataArtifactLoader loader)
在 System.Data.Entity.Core.Metadata.Edm.MetadataCache.<>c__DisplayClass5.<>c__DisplayClass7.<GetMetadataWorkspace>b__1()
在 System.Lazy`1.CreateValue()
在 System.Lazy`1.LazyInitValue()
在 System.Lazy`1.get_Value()
在 System.Data.Entity.Core.Metadata.Edm.MetadataCache.<>c__DisplayClass5.<>c__DisplayClass7.<GetMetadataWorkspace>b__4()
在 System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.LoadAndCheckItemCollection[T](Func`1 itemCollectionLoader)
在 System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.<>c__DisplayClass16.<.ctor>b__f()
在 System.Lazy`1.CreateValue()
在 System.Lazy`1.LazyInitValue()
在 System.Lazy`1.get_Value()
在 System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.GetItemCollection(DataSpace dataSpace, Boolean required)
在 System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.GetItemCollection(DataSpace dataSpace)
在 System.Data.Entity.Core.Objects.ObjectContext.InitializeMappingViewCacheFactory(DbContext owner)
在 System.Data.Entity.Core.Objects.ObjectContext..ctor(EntityConnection connection, Boolean isConnectionConstructor, ObjectQueryExecutionPlanFactory objectQueryExecutionPlanFactory, Translator translator, ColumnMapFactory columnMapFactory)
在 System.Data.Entity.Internal.InternalConnection.CreateObjectContextFromConnectionModel()
在 System.Data.Entity.Internal.LazyInternalConnection.CreateObjectContextFromConnectionModel()
在 System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
在 System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
在 System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
在 System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
在 System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()
在 System.Linq.Queryable.Where[TSource](IQueryable`1 source, Expression`1 predicate)
在 PaymentBLL.NewPayApplyBLL.GetPaidOrder(String orderNo, ThirdPayPlatformEnums thirdPayPlatform) 位置 d:\SourceProject\infrastructure.PayCenter\trunk\PaymentPlatform\PaymentBLL\NewPayApplyBLL.cs:行号 30
在 PaymentBLL.QRCodeBLL.Refund(String requestJson) 位置 d:\SourceProject\infrastructure.PayCenter\trunk\PaymentPlatform\PaymentBLL\QRCodeBLL.cs:行号 132
在 PaymentPlatform.QRCodeDemo.Refund.submit_Click(Object sender, EventArgs e) 位置 d:\SourceProject\infrastructure.PayCenter\trunk\PaymentPlatform\PaymentPlatform\QRCodeDemo\Refund.aspx.cs:行号 63

解决办法:

右键解决方案→管理Nuget程序包,选中“EntityFramework”,点击“管理”,在弹出框里选择要安装EF的项目,点击“OK”即可。

完成后,在web.config里多了如下节点配置:

<configuration>
  <configSections>
    <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">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
</configuration>

同时,引用里多了EntityFramework的2个包:

No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'

时间: 2024-12-31 13:21:17

No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'的相关文章

异常:error 0152: No Entity Framework provider found for the ADO.NET provider with invariant name &#39;System.Data.SqlClient&#39;

error 0152: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient' error 0152: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'. Make sure the pro

error 0152: No Entity Framework provider found for the ADO.NET provider with invariant name &#39;System.Data.SqlClient&#39;

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 发布站点时漏了EntityFramework.SqlServer

EntityFrame Work:No Entity Framework provider found for the ADO.NET provider with invariant name &#39;System.Data.SqlClient&#39;

今天试着学习了Entity Frame Work遇到的问题是 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.SqlCli

No Entity Framework provider found for the ADO.NET provider with invariant

在使用EF的时候,我把EF的EDMX放在单独的一个project中,UI中引用这个project的dll, 运行的时候就是提示No Entity Framework provider found for the ADO.NET provider with invariant 错误, 最后发现在UI项目中添加EF的引用就可以解决这个问题,而且是下面的两个DLL都要引用才行

无法为具有固定名称“System.Data.SqlClient”的 ADO.NET 提供程序加载在应用程序配置文件中注册的实体框架提供程序类型“System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer”。请确保使用限定程序集的名称且该程序集对运行的应用程序可用。有关详细信息,请参阅 http://go.m

Windows服务中程序发布之后会如下错误: 无法为具有固定名称"System.Data.SqlClient"的 ADO.NET 提供程序加载在应用程序配置文件中注册的实体框架提供程序类型"System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer".请确保使用限定程序集的名称且该程序集对运行的应用程序可用.有关详细信息,请参阅 http://go.microsoft.com

未找到具有固定名称“System.Data.SqlClient”的 ADO.NET 提供程序的实体框架 解决方案

今天在做EF ORM框架时,发生了一个异常: "无法为具有固定名称"System.Data.SqlClient"的 ADO.NET 提供程序加载在应用程序配置文件中注册的实体框架提供程序类型"System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer".请确保使用限定程序集的名称且该程序集对运行的应用程序可用." 问题原因:这是由于项目缺少对EntityF

Entity Framework 学习总结之一:ADO.NET 实体框架概述

http://www.cnblogs.com/xlovey/archive/2011/01/03/1924800.html ADO.NET 实体框架概述 新版本中的 ADO.NET 以新实体框架为特色.它使开发人员可以通过对象模型(而不是逻辑/关系数据模型)专注于数据.实体框架有助于将逻辑数据架构抽象为概念模型,并且允许以多种方式通过对象服务和名为“EntityClient”的新数据提供程序与概念模型交互. 实体框架使用概念层(ConceptualModels).映射层(Mappings)和逻辑

发生了 System.Data.SqlClient.SqlException HResult=0x80131904 Message=在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。未找到或无法访问服务器。请验证实例名称是否正确并且 SQL Server 已配置为允许远程连接。 (provider: Named Pipes Provider, error: 40 -

刚刚一运行出现了这个错误,一看知道是数据库出问题了. 打开数据库,果然是这样. 标题: 连接到服务器 ------------------------------  无法连接到 ..  ------------------------------ 其他信息: 未找到或无法访问服务器.请验证实例名称是否正确并且 SQL Server 已配置为允许远程连接. 解决方法: 是没有连上实例~先点取消,在"查看"中选"已注册的服务器",展开"数据库引擎"

Entity Framework使用Sqlite时的一些配置

前段时间试着用Entity Framework for Sqlite环境,发现了一些坑坑洼洼,记录一下. 同时试了一下配置多种数据库,包括Sqlite.Sql Server.Sql Server LocalDB.Sql Server Compact. 我建的demo项目结构以及通过NuGet安装的包:   EFDemo.MultipleDB.UI引用了EFDemo.MutipleDB项目. 1. 遇到的异常1 The Entity Framework provider type 'System.