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?!

Solution

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

18 comments:

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

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

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

    ReplyDelete
  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:






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

    ReplyDelete
  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 https://fix4dll.com/msvcr120_dll and easy fix the problem, maybe it's just because that you have the wrong file.

    ReplyDelete
  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?

    ReplyDelete
  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

    ReplyDelete
  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.

    ReplyDelete
  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

    ReplyDelete
  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

    ReplyDelete
  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 http://webslivesupport.com/aol-desktop-gold/
    Download AOL desktop gold
    AOL desktop gold download
    Download and install AOL desktop gold

    ReplyDelete
  13. If you need support related to your AOL mail, whether it is a normal login, password, email attachment, password reset, email configuration and other issues, you can contact us by dialing our AOL email support phone number. Our expert team listens carefully to our customers and fixes their email errors step by step. We provide services through many methods such as calls, chat and remote access. Our team is highly experienced, skilled and dedicated to our email support services. Just visit our website http://webslivesupport.com/aol-desktop-gold/
    Download AOL desktop gold
    AOL desktop gold download
    Download and install AOL desktop gold



    ReplyDelete
  14. It is not uncertain whether users may encounter problems while using email services and during a certain period of time they may encounter an error during a critical period. But, this can be dealt with soon, all you need to do is dial an email support number to get an email help and get rid of the problem.You need to visit our website http://webslivesupport.com/
    email support number
    email customer care numberr
    Download AOL desktop gold
    AOL desktop gold download



    ReplyDelete
  15. hello,Its really nice post.Thanks For sharing a good post.Something else I would like to talk about is that Max Global Support.Do you know how to return a DIRECTV receiver? If you would like to know how you need to return DIRECTV equipment,you need to know which ones AT&T wants back. It’s a simple process where you can return DIRECTV equipment to the company.Just click here to follow the steps… DirecTV return equipmentand also call on toll free technical support phone number +1-888-957-7111, to solve your problem within a minutes.

    ReplyDelete