WCF RIA 服务和Windows Azure =>;实体没有定义键
背景信息
在使用 Windows Azure 和 WCF RIA 服务进行开发时,我见过很多随机错误和总体令人沮丧的情况,但这确实是巅峰之作。
我有一个具有以下架构的应用程序:2 个 Web 角色(MVC3 和带有 Silverlight RIA 的 ASP.NET)=>业务层=>数据层(外部服务/表存储/SQL Azure)。 ASP.NET 服务(配置文件/角色/会话)存储在表存储中。
由于最近的要求发生变化,需要添加移动站点。我想共享两个 GUI 项目的(服务器端)ViewModel。举例说明:
我的问题
我现在遇到了可怕的“未找到”异常当我的项目托管在 Windows Azure 环境中时。使用 fiddler 我发现它返回以下异常:
DomainService“XXService”中的实体“XXModel”不 定义了一个键。 DomainService 操作公开的实体类型 必须至少有一个用 KeyAttribute 标记的公共属性。
奇怪的是,这个东西在本地Azure开发环境中运行完美,但上传到云端时就不行了。我认为这个错误与 ViewModel 现在与 RIA 服务位于不同的程序集中有关,但为什么它会在本地而不是远程工作?
如果有人需要任何补充信息,我将很乐意回答您的问题。
Background Info
Developing with Windows Azure and WCF RIA Services, I have seen a lot of random errors and overall frustrating situations, but this one is really the pinnacle.
I have an application with the following architecture: 2 web roles (MVC3 and ASP.NET with Silverlight RIA) => Business layer => data layer (external services / table storage / SQL Azure).
ASP.NET services (profile/roles/sessions) are stored in Table Storage.
Due to recent requirement changes, a mobile site needed to be added. I wanted to share the (server side) ViewModels for both GUI projects. To illustrate:
My problem
I now get the dreaded "Not Found" exception when my project is hosted in the Windows Azure environment. With fiddler I found that it was returning the following exception:
The Entity 'XXModel' in DomainService 'XXService' does not
have a key defined. Entity types exposed by DomainService operations
must have at least one public property marked with the KeyAttribute.
The strange thing is that this thing runs flawlessly in the local Azure development environment, but not when uploaded into the cloud. I think that this error has something to do with the ViewModels now being in a different assembly than the RIA Services, but why would it work locally and not remotely?
If anyone needs any supplemental information I will be happy to answer your questions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经解决了这个问题。看起来,只有在 Windows Azure 中托管时,RIA 服务似乎无法从与托管服务的程序集不同的程序集中定义的模型类中获取属性。
I have solved the problem. It seems that RIA Services, only when hosted in Windows Azure, cannot seem to get the attributes off of model classes defined in a different assembly then the one hosting the services.
您的实体是否有标有 [Key] 属性的属性?例如:
这对于 RIA DomainServices 使用的类型是必需的 - 正如您问题中的错误消息中所述。
虽然我不知道为什么它可以在开发环境中运行,而不是在真实环境中运行。
Does your entity have a Property marked with the [Key] attribute? e.g.:
This is necessary for the types used with RIA DomainServices - as stated in the error message in your question.
Although I don't know why it would work on a development environment and not in a real environment one.