Duck -Day 3

You can’t get too complacent in this game, I had a terrible day today, I have created 1 entity model Entities.edmx generated from the SQL db and that had been fine all day.

Suddenly it stops working and I’m getting the error:

MetadataException: Unable to load the specified metadata resource

I tried deleting and recreating the edmx file, no change. Renaming it then changing the code, still nothing. I checked the connection string, it was creating and it looked fine:

connectionString=”metadata=res://*/Entities.csdl|res://*/Entities.ssdl|res://*/Entities.msl;provider=System.Data.SqlClient;provider connection string="data source=xxxx;initial catalog=ctl;multipleactiveresultsets=True;application name=EntityFramework"” providerName=”System.Data.EntityClient”

It wasn’t looking good, so off to Google and Stackoverflow et al. I eventually came across this:

The answer that worked for me was to simply enter the assemblyname to replace the * in the connection string I then deleted and regenerated the same name edmx file in the wizard and ignored the generated connection string, but I suspect it would of worked as is and was probably just superstitious at the time.

Not sure how the problem happened, it might of been when I was regenerating the entity model.

I used to delete the model and regenerate it after a significant amount of stored procedure changes have occurred, but from now on I will only do a refresh for table changes and remove and re-add stored procedures to get the latest ones. My previous method messed up TFS anyway.

Good to see the code working again… good night.

Dave Riley loves the Internet and has been online since 1993, he is a software developer, internet marketer and MBA student. Over 22 years of software development experience.

Tagged with: ,
One comment on “Duck -Day 3
  1. Kia says:

    Hi Jose9,The only way to do this currently is to gteerane an EDMX and then have EF load that EDMX instead of building the model from code each time. You can gteerane the EDMX from a Code First model using the EdmxWriter class. I believe that the EF Power Tools can also do this. Once you have an EDMX you can add it to your VS project as an existing item and then you would reference it using a Database First -style EF connection string. Hopefully you can figure out the details. Let me know if you get stuck.The other thing to check is that it is the model building that is taking the time and not view generation. You might want to look into using pre-generated views if you haven’t already.Thanks,Arthur

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.