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

元气小坏坏 提交于 2019-12-23 12:11:53

问题


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,

BAL (Business Layer) is having reference of both Project

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


回答1:


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.



来源:https://stackoverflow.com/questions/29797153/issue-after-uploading-to-azure-with-ef-unable-to-load-the-specified-metadata-res

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!