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

70,468

Solution 1

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

Solution 2

I was getting an exception like this. The problem was that I renamed my .edmx file and forgot to change the name in EF Web.config file's connection string:

metadata=res://*/MyModel.csdl|res://*/MyModel.ssdl|res://*/MyModel.msl;

Solution 3

The easiest solution that resolved this for me was to remove the obj folder which sit at the same level as the bin folder and re-run the application, my god it took way longer than it needed

Solution 4

I used EntityFramework 6.0 in one solution which included multiple projects such as WebSite level project, DataAccess level project. In my solution, the migrations should be happened in DataAccess level project.

When I run Add-Migration command in Package Manager Console, raised "Unable to load the specified metadata resource".

Finally, I found I set the WebSite level project as "Startup" project and this trigger above exception. It seems system will auto checking the connection string settings in the StartUp project first. And my data connection string set in WebSite level project is

"metadata=res:///ApplicationEntities.csdl|res:///ApplicationEntities.ssdl|res://*/ApplicationEntities.msl;provider=System.Data.SqlClient;provider connection string="data source=.;initial catalog=YourDatabaseName;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework""

which is not correct for code first.

The correct connection string should be:

"Data Source=.;Initial Catalog=YourDatabaseName;Integrated Security=True"

Conclusion, always check the "connectionStrings" section in web.config in the "StartUp" project of solution first.

Solution 5

I also encountered this problem and it was because I was going from Entity Framework Model First to Entity Framework Code First, and had forgotten to change the EDMX connectionstring to a 'regular' connection string.

Share:
70,468
Meysam Savameri
Author by

Meysam Savameri

Updated on May 01, 2021

Comments