If you encounter the error: “Invoke operation ‘MyOperation’ failed. Unable to load the specified metadata resource”. Please check the connection string used by Entity Framework.

In my case, I changed the namespace for the *.edmx file, but forgot to change the namespace in the connection string in the Web.config:

 

I placed the *.edmx file in a folder Models en changed the namespace, so the following connection string was wrong:

<add name=”MyModel” connectionString=”metadata=res://*/MyModel.csdl  ………………………

 

Should be
<add name=”MyModel” connectionString=”metadata=res://*/Models.MyModel.csdl ……………………………….

 

StackTrace

at System.Data.Metadata.Edm.MetadataArtifactLoaderCompositeResource.LoadResources(String assemblyName, String resourceName, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver)
at System.Data.Metadata.Edm.MetadataArtifactLoaderCompositeResource.CreateResourceLoader(String path, ExtensionCheck extensionCheck, String validExtension, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver)
at System.Data.Metadata.Edm.MetadataArtifactLoader.Create(String path, ExtensionCheck extensionCheck, String validExtension, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver)
at System.Data.Metadata.Edm.MetadataCache.SplitPaths(String paths)
at System.Data.Common.Utils.Memoizer`2.<>c__DisplayClass2.<Evaluate>b__0()
at System.Data.Common.Utils.Memoizer`2.Result.GetValue()
at System.Data.Common.Utils.Memoizer`2.Evaluate(TArg arg)
at System.Data.EntityClient.EntityConnection.GetMetadataWorkspace(Boolean initializeAllCollections)
at System.Data.Objects.ObjectContext.RetrieveMetadataWorkspaceFromConnection()
at System.Data.Objects.ObjectContext..ctor(EntityConnection connection, Boolean isConnectionConstructor)
at System.Data.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName)

 

An other create resource for resolving this problem is: http://blogs.teamb.com/craigstuntz/2010/08/13/38628/

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.