Metadataexception: Unable to Load the Specified Metadata Resource

MetadataException: Unable to load the specified metadata resource

This means that the application is unable to load the EDMX. There are several things which can cause this.

  • You might have changed the MetadataArtifactProcessing property of the model to Copy to Output Directory.
  • The connection string could be wrong. I know you say you haven't changed it, but if you have changed other things (say, the name of an assembly), it could still be wrong.
  • You might be using a post-compile task to embed the EDMX in the assembly, which is no longer working for some reason.

In short, there is not really enough detail in your question to give an accurate answer, but hopefully these ideas should get you on the right track.

Update: I've written a blog post with more complete steps for troubleshooting.

Entity Framework - Unable to load the specified metadata resource

So I've got to the bottom of this, partly I think this was my fault. I'll put solutions to each issue I encountered below in case it helps anyone else.

Unable to load the specified metadata resource issue

This was caused by me setting the 'Metadata Artifact Processing' setting on the edmx model from "EntityDeploy" to "Embedded Resouce".

So this meant it just embedded the whole edmx file file into the dll and didn't generate the ssdl, msl and csdl files instead.

I guess you have to set this to EntityDeploy for this to work and generate these files correctly. Makes perfect sense and our bad over here.

Unable to resolve assembly 'DllName.dll'

This was resolved by Andrew in the comments above, thanks for the pointer on that.

Could not find the Conceptual Schema node to embed as a resource for input file

The key to this whole issue really is this, our build server is currently on Windows 2003, so can't have .NET 4.5 installed, locally we were using EF 6.1 running under .NET 4.0 on VS2013.

However for some reason it looks like we need to have .NET 4.5 installed on our build server to get this to build even though we're not using any of the 4.5 features and targetting the .NET 4 framework.

Downgrading to EF to 4.3 solved this issue for us in the short term. Not ideal but it worked.

ASP MVC, EF Code first Unable to load the specified metadata resource (without edmx)

Your connection string is for a database first context. For code first, you should use a simpler version, which contains only the information to connect to the database (metadata are created dynamically). For your case, try with this:

<add name="Context" connectionString="Server=127.0.0.1,2014;Database=myDbName;User Id=sa;Password=myPassword;multipleactiveresultsets=True;application name=EntityFramework" providerName="System.Data.SqlClient" />

Entity Framwork Unable to Load the specified metadata resource

This worked for me.

Changing from this:

connectionString="metadata=res://*/Model.Project.csdl|res://*/Model.Project.ssdl|res://*/Model.Project.msl;

change to:

connectionString="metadata=res://*/;

And add the rest of your connection string after. Hope it helps.

System.Data.MetadataException: Unable to load the specified metadata resource

Refer to http://forums.devart.com/viewtopic.php?t=22092 .

If this doesn't help, please specify:

  • are you working with ADO.NET Entity Data Model (.edmx) or Devart Entity Model (.edml)?
  • the value of your model file's Build Action property
  • the value of the Metadata Artifact Processing property of your model
  • the build number (x.xx.xxx) of your dotConnect for Oracle
  • the version of your Visual Studio
  • follow Pawel's advice to check if resources were embedded in
    the assembly

Unable to load the specified metadata resource

The metadata parameter for an application with an Entity Framework model called Model.edmx in an assembly called Simple Mvc.Data.dll might look like this:

<connectionStrings>
<add name="MyEntities" connectionString="metadata=
res://Simple Mvc.Data.dll/Model.csdl|
res://Simple Mvc.Data.dll/Model.ssdl|
res://Simple Mvc.Data.dll/Model.msl;provider= <!-- ... -->

So you can see there is one reference for each of the three parts of the EDMX that we need at runtime. They all work in the same way, so let’s examine just the first more closely. The CSDL reference looks like this:

        res://Simple Mvc.Data.dll/Model.csdl

It specifies three things:

  • We’re loading the CSDL from a resource. That’s the "res://" part.

  • The name of the assembly which contains the resource, "Simple Mvc.Data.dll". If your assembly is strong named, you can specify a strong name, in all its verbose glory, here.

  • The name of the resource itself, "Model.csdl". Do not confuse this with the EDMX or model name. In this case they happen to be the same, except for the extension, but that’s not always true!

It will probably fail if your resources don’t happen to have the same
name as your model, or if the assembly doesn’t happen to be loaded.

For more information check this out Troubleshooting Entity Framework Connection Strings

I hope this will help to you.

Entity Framework: Unable to load the specified metadata resource

After reading this answers article and this blog I changed:

  entity.Metadata = @"res://*/Data.System.csdl|res://*/Data.System.ssdl|res://*/Data.System.msl";

To:

  entity.Metadata = "res://*/";

And it works :-)



Related Topics



Leave a reply



Submit