Wednesday, May 11, 2016

Entity Framework-Unable to load the specified metadata resource

I was working on updating my application with a newer version of Entity Framework when I suddenly encountered the following error message:


Based on a few discussion forum posts, there was a mention that the name of the .csdl, .ssdl and .msl files may have been incorrect/invalid in the Entity Framework connection string.

Well, based on looking at my connection string, I noticed that was indeed the case!

When I re-generated my Entity Framework Designer Model, I ended up changing the name of the underlying EDMX model file which consequently changed all of the names that are also required in the Entity Framework connection string.

Therefore, I had something like the following:

<add name="MyEntities" connectionString="metadata=res://*/OldModel.csdl|res://*/OldModel.ssdl|res://*/OldModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=(local);initial catalog=MyCatalog;user id=sa;password=P@ssword!;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" />

Since the EDMX model names were invalid, I had to change it to the following:


<add name="MyEntities" connectionString="metadata=res://*/NewModel.csdl|res://*/NewModel.ssdl|res://*/NewModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=(local);initial catalog=MyCatalog;user id=sa;password=P@ssword!;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" />

That was all that was needed to resolve my issue!

3 comments:

  1. Marks4sure Questions and Answers provide you to the point, precise and comprehensive knowledge of the entire syllabus in select Q&As. Marks4sure.org dumps consist of the gist of the topics covered in a certification syllabus outline. marks4sure

    ReplyDelete
  2. I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. In fact your creative writing abilities has inspired me to start my own Blog Engine blog now. Really the blogging is spreading its wings rapidly. Your write up is a fine example of it. business analytics course in kanpur

    ReplyDelete
  3. 360DigiTMG, the top-rated organisation among the most prestigious industries around the world, is an educational destination for those looking to pursue their dreams around the globe. The company is changing careers of many people through constant improvement, 360DigiTMG provides an outstanding learning experience and distinguishes itself from the pack. 360DigiTMG is a prominent global presence by offering world-class training. Its main office is in India and subsidiaries across Malaysia, USA, East Asia, Australia, Uk, Netherlands, and the Middle East.

    ReplyDelete