使用EF上传到azure后出现问题无法加载指定的元数据资源错误 [英] Issue after uploading to azure with EF Unable to load the specified metadata resource error

查看:154
本文介绍了使用EF上传到azure后出现问题无法加载指定的元数据资源错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ASP.net MVC5应用程序和EF 5 Model第一种方法。但是也使用了另一个名为Entity的C#项目的poco类。



我正在使用多层架构,其中Edmx文件位于DAL层,BAL正在参考它和BAL和实体项目在主要Web项目中引用。



当我的网站尝试连接数据库时,一切都很好,但在 Azure 设置数据库和项目后,它会抛出错误MetadataException:Unable加载指定的元数据资源



我陷入了两天的问题,并尝试在stackoverflow或任何其他博客中提供的所有可能的解决方案。但是相信我们,没有什么可以帮助我,就像给出完整的装配路径一样。使用metadata = res:// * /;也没有为我工作,我在这里很大的压力。



请帮助我
截图并附加了web.config中的连接字符串。

 < add name =questmysqlEntitiesconnectionString =metadata = res: /QuestCloud/QuestCloudDAL/QuestCloud.csdl|res://QuestCloud/QuestCloudDAL/QuestCloud.ssdl|res://QuestCloud/QuestCloudDAL/QuestCloud.msl;provider=System.Data.SqlClient;provider connection string =& quot;数据源****** servername ****;初始目录= questdb; Persist Security Info = True; user id = **** username ****; password = **** password ****; MultipleActiveResultSets = True;应用程序名称= EntityFramework& quot;providerName =System.Data.EntityClient/> 

我的Edmx文件驻留在DAL(数据库层)项目中,POCO模板驻留在实体项目中,





BAL(业务层)正在引用Project





我的Web项目引用了BAL(业务层)和实体项目



解决方案

我得到了以上的解决方案。我刚刚将 QuestCloudDAL.dll 的引用添加到我的主项目 QuestCloud 中。并且还将这个程序集的引用放在我的主要web.config中,

 < add name =questmysqlEntitiesconnectionString = metadata = res://QuestCloudDAL/QuestCloud.csdl | res://QuestCloudDAL/QuestCloud.ssdl | res://QuestCloudDAL/QuestCloud.msl; provider = System.Data.SqlClient; provider connection string =& quot; Data源****** servername ****;初始目录= questdb; Persist Security Info = True; user id = **** username ****; password = **** password ****; MultipleActiveResultSets = True;应用程序名称= EntityFramework& quot; providerName =System.Data.EntityClient/> 

而不是*,我把 QuestCloudDAL 命名空间元数据资源在we.config连接字符串中。而且它按预期工作。


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

解决方案

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.

这篇关于使用EF上传到azure后出现问题无法加载指定的元数据资源错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆