关于System.Data.Entity.Core.MetadataException错误

发布ASP.NET MVC到IIS后出现错误:

 1 System.Data.Entity.Core.MetadataException: Schema specified is not valid. Errors:
 2 SysModel.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.
 3    at System.Data.Entity.Core.Metadata.Edm.StoreItemCollection.Loader.ThrowOnNonWarningErrors()
 4    at System.Data.Entity.Core.Metadata.Edm.StoreItemCollection.Loader.LoadItems(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths)
 5    at System.Data.Entity.Core.Metadata.Edm.StoreItemCollection.Loader..ctor(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, Boolean throwOnError, IDbDependencyResolver resolver)
 6    at 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)
 7    at System.Data.Entity.Core.Metadata.Edm.StoreItemCollection..ctor(IEnumerable`1 xmlReaders, IEnumerable`1 filePaths)
 8    at System.Data.Entity.Core.Metadata.Edm.MetadataCache.LoadStoreCollection(EdmItemCollection edmItemCollection, MetadataArtifactLoader loader)
 9    at System.Data.Entity.Core.Metadata.Edm.MetadataCache.<>c__DisplayClass5.<>c__DisplayClass7.<GetMetadataWorkspace>b__1()
10    at System.Lazy`1.CreateValue()
11    at System.Lazy`1.LazyInitValue()
12    at System.Lazy`1.get_Value()
13    at System.Data.Entity.Core.Metadata.Edm.MetadataCache.<>c__DisplayClass5.<>c__DisplayClass7.<GetMetadataWorkspace>b__4()
14    at System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.LoadAndCheckItemCollection[T](Func`1 itemCollectionLoader)
15    at System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.<>c__DisplayClass16.<.ctor>b__f()
16    at System.Lazy`1.CreateValue()
17 --- End of stack trace from previous location where exception was thrown ---
18    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
19    at System.Lazy`1.get_Value()
20    at System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.GetItemCollection(DataSpace dataSpace, Boolean required)
21    at System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.GetItemCollection(DataSpace dataSpace)
22    at System.Data.Entity.Core.Objects.ObjectContext.InitializeMappingViewCacheFactory(DbContext owner)
23    at System.Data.Entity.Core.Objects.ObjectContext..ctor(EntityConnection connection, Boolean isConnectionConstructor, ObjectQueryExecutionPlanFactory objectQueryExecutionPlanFactory, Translator translator, ColumnMapFactory columnMapFactory)
24    at System.Data.Entity.Internal.InternalConnection.CreateObjectContextFromConnectionModel()
25    at System.Data.Entity.Internal.LazyInternalConnection.CreateObjectContextFromConnectionModel()
26    at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
27    at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
28    at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
29    at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
30    at System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()
31    at System.Linq.Queryable.OrderBy[TSource,TKey](IQueryable`1 source, Expression`1 keySelector)
32    at YF.DateServices.SysServices.NavMenuService.GetMenus()
33    at YF.Web.Areas.Sys.Controllers.NavMenuController.GetMenus()
34    at lambda_method(Closure , ControllerBase , Object[] )
35    at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
36    at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
37    at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
38    at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
39    at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
40    at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
41    at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
42    at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
43    at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
44    at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
45    at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult)
46    at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult)
47    at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
48    at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)
49    at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<>c__DisplayClass2b.<BeginInvokeAction>b__1c()
50    at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)

查询bin文件下是否有EntityFramework.SqlServer.dll文件。

时间: 2024-10-05 15:57:56

关于System.Data.Entity.Core.MetadataException错误的相关文章

使用EF6.0出现:CS0029 无法将类型“System.Data.Entity.Core.Objects.ObjectContext”隐式转换为“System.Data.Objects.ObjectContext”错误

这是因为EF6.0重构了一些命名空间后,和VS原有的实体数据模型模板不一致了(ObjectContext context = ((IObjectContextAdapter)dataContext).ObjectContext;),只要把命名空间改一下就可以了,如下: 把using System.Data.Objects;改成using System.Data.Entity.Core.Objects;即可.

Entity Framework优化一:引发了“System.Data.Entity.Core.EntityCommandExecutionException”类型的异常

错误信息: “System.Data.Entity.Core.EntityCommandExecutionException”类型的异常在 EntityFramework.SqlServer.dll 中发生,但未在用户代码中进行处理. 其他信息:执行命令定义时出错.有关详细信息,请参阅内部异常. 跟踪代码找到详细信息: Entity Framework已有打开的与此Command相关联的DataReader,必须首先将它关闭. EF内部是使用DataReader作为资料存取,所以如果没关闭连接就

System.Security.SecurityException The type initializer for &#39;System.Data.Entity.Internal.AppConfig&#39; threw an exception

[15/08/19 00:03:10] [DataManager-7292-ERROR] System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'System.Data.Entity.Internal.AppConf

编译器错误消息:必须添加对程序集“System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”的引用

出现这个错误的原因是Web.config配置文件的原因. 解决办法: 在web.config中的<system.web>节点下的<system.web>节点下的<assemblies>中添加: <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> 编译器错误消息:必须添加对程序集&qu

EF生成 类型“System.Data.Entity.DbContext”在未被引用的程序集中定义

错误描述: 1 类型“System.Data.Entity.DbContext”在未被引用的程序集中定义.必须添加对程序集“EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”的引用. D:\HF_Source\webapitest\test2\DFSoft.Plat.SQLServerDAL\BaseService\B_AgreementTypeDAL.cs 30 13 DFSof

The type initializer for &#39;System.Data.Entity.Internal.AppConfig&#39; threw an exception.

当使用EF时,配置文件中会多出下面的配置代码: <configSections> <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> <section name="entityFramework" type="System.Data.Entity.Internal.C

在mvc返回JSON时出错:序列化类型为“System.Data.Entity.DynamicProxies.Photos....这个会的对象时检测到循环引用 的解决办法

在MVC中返回JSON时出错,序列化类型为“System.Data.Entity.DynamicProxies.Photos....这个会的对象时检测到循环引用. public ActionResult GetSdirsbyFdirid(int id) { // db.Configuration.LazyLoadingEnabled = false; db.Configuration.ProxyCreationEnabled = false; List<Seconddirectory> lis

报错:System.Data.Entity.Validation.DbEntityValidationException: 对一个或多个实体的验证失败

使用MVC和EF,在保存数据的时候报错:System.Data.Entity.Validation.DbEntityValidationException: 对一个或多个实体的验证失败.有关详细信息,请参阅"EntityValidationErrors"属性. 日志记录中,出错的地方在result += db.SaveChanges();所在行,尝试如下操作: →使用try...catch捕获→在catch所在行打上断点,运行,F11,对ex变量添加监视→在EntityValidati

使用EF访问数据库,出现“System.Data.Entity.Internal.AppConfig”的类型初始值设定项引发异常。

今天在使用的EF时候,发生了"System.Data.Entity.Internal.AppConfig"的类型初始值设定项引发异常.这样的一个错误 查了原因,原来是appconfig中,connectionStrings的位置放错了.因为configSections必须是appconfig的第一个节点 这样是不对的. 应该是 感觉这种情况应该不仅仅只限于这个EF,只要configSections不是第一个标签就会有问题,也适用于其他情况~~