3
votes

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:

enter image description here

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.

2
Are you still correctly bin-deploying all the pieces? RIA, Azure SDK, and your assemblies all need it.Kyle McClellan
Yeah, all assemblies are being deployed, it has worked before on the same project.Bas
Have you re-built the project in a clean directory in your development environment? I wondering if perhaps you have some artifacts from a previous build that are masking the problem. This wouldn't solve your problem, but it would explain the discrepancy between development vs. deployment.Paul Keister
@Paul Keister I have tried this, to no avail :(Bas
Sorry to waste your time with this. I was thinking that since RIA Services relies on "projected" code, that the code generation output might not be in sync locally. Apparently that's not the problem.Paul Keister

2 Answers

1
votes

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.

0
votes

Does your entity have a Property marked with the [Key] attribute? e.g.:

public class WidgetDef
{
    [Key]
    public int WidgetId { get; set; }

    public string Title { get; set; }
}

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.