Search code examples
asp.net-mvcentity-frameworkazurerazorpoco

Issue after uploading to azure with EF Unable to load the specified metadata resource error


I am working with ASP.net MVC5 Application and with EF 5 Model first approach. But also used poco classes, which is in another C# project called "Entity".

I am having multi-tier architecture where Edmx file is in DAL layer and BAL is having reference of it and BAL and Entity Project are referenced in main web project.

Everything works well but after setting up the database and project on Azure when my site tries to connect database it throws below error "MetadataException: Unable to load the specified metadata resource"

I am stuck in an issue for two days and tried with every possible solution given in stackoverflow or in any other blogs. But believe me guys nothing working me for out like giving the full path of assembly , dll in meta deta. using "metadata=res://*/; also didn't worked for me. I am in big stress here.

Please help me. Screenshots and connection string in web.config is attached.

<add name="questmysqlEntities" connectionString="metadata=res://QuestCloud/QuestCloudDAL/QuestCloud.csdl|res://QuestCloud/QuestCloudDAL/QuestCloud.ssdl|res://QuestCloud/QuestCloudDAL/QuestCloud.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source******servername****;Initial Catalog=questdb;Persist Security Info=True;user id=****username****;password=****password****;MultipleActiveResultSets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" />

My Edmx file reside in DAL (Database Layer) Project and POCO Template reside in Entity project,

enter image description here

BAL (Business Layer) is having reference of both Project

enter image description here

My Web Project is having reference of BAL (Business Layer) and Entity project

enter image description here


Solution

  • I got the solution of above probelm. I have just added the reference of "QuestCloudDAL.dll" into my main project QuestCloud. And also put the reference of this assembly in my main web.config as,

     <add name="questmysqlEntities" connectionString="metadata=res://QuestCloudDAL/QuestCloud.csdl|res://QuestCloudDAL/QuestCloud.ssdl|res://QuestCloudDAL/QuestCloud.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source******servername****;Initial Catalog=questdb;Persist Security Info=True;user id=****username****;password=****password****;MultipleActiveResultSets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" />
    

    instead of "*", i have put "QuestCloudDAL" namespace for metadata resources in we.config connection string. And it works as expected.