.NET绿叶社区!
返回

HResult=0x80131939 Message=无法加载指定的元数据资源。异常处理

用EntityFramework的时候抛出以下异常:

System.Data.Entity.Core.MetadataException

  HResult=0x80131939

  Message=无法加载指定的元数据资源。

  Source=EntityFramework

  StackTrace:

   在 System.Data.Entity.Core.Metadata.Edm.MetadataArtifactLoaderCompositeResource.LoadResources(String assemblyName, String resourceName, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver)

   在 System.Data.Entity.Core.Metadata.Edm.MetadataArtifactLoaderCompositeResource.CreateResourceLoader(String path, ExtensionCheck extensionCheck, String validExtension, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver)

   在 System.Data.Entity.Core.Metadata.Edm.MetadataArtifactLoader.Create(String path, ExtensionCheck extensionCheck, String validExtension, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver)

   在 System.Data.Entity.Core.Metadata.Edm.MetadataCache.SplitPaths(String paths)

   在 System.Data.Entity.Core.Common.Utils.Memoizer`2.<>c__DisplayClass2.<Evaluate>b__0()

   在 System.Data.Entity.Core.Common.Utils.Memoizer`2.Result.GetValue()

   在 System.Data.Entity.Core.Common.Utils.Memoizer`2.Evaluate(TArg arg)

   在 System.Data.Entity.Core.Metadata.Edm.MetadataCache.GetArtifactLoader(DbConnectionOptions effectiveConnectionOptions)

   在 System.Data.Entity.Core.Metadata.Edm.MetadataCache.GetMetadataWorkspace(DbConnectionOptions effectiveConnectionOptions)

   在 System.Data.Entity.Core.EntityClient.EntityConnection.GetMetadataWorkspace()

   在 System.Data.Entity.Core.Objects.ObjectContext.RetrieveMetadataWorkspaceFromConnection()

   在 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.Initialize()

   在 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)

...

回复

已解决,是因为删除了EF对象后有新建了一个,导致项目中的连接字符串和新创建的连接字符串不一致导致的,把EF所在类库里的App.Config里的连接字符串复制到运行的站点或者WinForm项目里的Config里就好了

回复
回复 楼主
顶部