find a location for property in a new city

Thursday, 24 June 2010

Entity Framework MetadataException: Unable to load the specified metadata resource

I got a "System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation" error with a description of "System.Data.MetadataException: Unable to load the specified metadata resource. at System.Data.Metadata.Edm.MetadataArtifactLoaderCompositeResource.LoadResources".

This occurred when I was trying to move my Models out of my main MVC web application assembly. The main web dll is called Web and within that project is a folder called Models that is used to store all my *ahem* Models and entity data models etc. I decided to move everything in the Models folder out into its own Models assembly. I edited all the namespaces and everything built okay.

However, I was getting a runtime MetadataException when trying to view the page. What the hell is going on?!


The problem is that the connection string was incorrect. It wasn't immediately obviously with that error message but when you think about it, it makes sense.

My connection string was: connectionString="metadata=res://*/Models.Messaging.MessagingObjects.csdl|res://*/Models.Messaging.MessagingObjects.ssdl|res://*/Models.Messaging.MessagingObjects.msl;....etc"

Just so you know the metadata represents this metadata=res://{assembly}/{namespace}.{filename}.csdl|res://{assembly}/{namespace}.{filename}.ssdl|res://{assembly}/{namespace}.{filename}.msl;

Since I have moved the models around and the namespace is now different I needed to make it connectionString="metadata=res://*/Messaging.MessagingObjects.csdl|res://*/Messaging.MessagingObjects.ssdl|res://*/Messaging.MessagingObjects.msl;

Just for further understanding I could have replaced the asterix with Models since that is the name of the dll that contains my Messaging models.

Follow britishdev on Twitter


  1. Thanks for the post, solved my issue I was having!

  2. Great, I had exactly the same problem right now and solved it with your help. thank you so much!

  3. Thank you so much...did not consider it at all...

  4. I am using model first. I generated the domain classes and moved them into a separate project. I also move the context to a separate class. I changed my app config file to add the namespace. I still get the message. I also tried adding the assembly name. That caused a different problem. I have the app config file in my model, domain and context assembly. Same config file in each case. My config file is:

  5. Nice post, helped me figure this app out!! Thanks!!

  6. You have found a good solution for this problem. I will use this today. Thanks for the article, and in case you'll be looking for another dll file, you can use the msvcr120.dll download and easy fix the problem, maybe it's just because that you have the wrong file.

  7. Hi, I am new to EF. I created an edmx file for my project. I get the same metadata error mentioned here. To try the solutions provided here, can someone tell me how/where to find the names for the namespace and assembly?

  8. Bài viết rất hay: Chúng tôi có các dịch vụ in ấn chuyên nghiệp sau:

    in bao bì vỏ hộp

    in hộp bìa cứng

  9. This seems to be really great. if you are looking for AOl Customer Service then you can contat at AOl tech Support Phone Number for help. they will guide you to resolve your issue as soon as possible.

  10. Bài viết của bạn rất hay!

    Công ty In Ấn Phúc Nguyên cung cấp các dịch vụ giá rẻ nhất tại hà nội:

    Báo giá in thùng carton giá rẻ nhất

    in bao bì tại hà nội

    in hộp cứng

  11. This is a great inspiring article. I am pretty much pleased with your good work. You put really very helpful information.
    AOL Technical Support Number

  12. There are many software which are continuously being introduced in the market due to technological advancements. Many companies try to launch different types of software that prove to be user-friendly and have the goal of achieving its maximum popularity. Telecom company AOL Inc. is quite well known and known for delivering elite quality products and services in the market. You need to download AOL desktop gold in your computer to enjoy seamless services by AOL. You need to visit our website
    Download AOL desktop gold
    AOL desktop gold download
    Download and install AOL desktop gold