So i have been playing around with the .NET RIA Services with Silverlight, and i created a new DomainService based on a couple entities from a LINQ2SQL DataContext.
When i tried to compile, i got this error:
Error 2 The entity 'Data.Service' does not have a key defined. Entities exposed by DomainService operations must have must have at least one property marked with the KeyAttribute. Portal
So i added a metadata class for the Service object like so:
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
namespace Data
{
[MetadataType(typeof(Service.ServiceMetadata))]
public partial class Service
{
internal sealed class ServiceMetadata
{
[Key]
public int PublicAPI;
}
}
}
Now i get this error:
Error 4 The associated metadata type for type 'Data.Service' contains the following unknown properties or fields: PublicAPI. Please make sure that the names of these members match the names of the properties on the main type. Portal
PublicAPI is definitely defined in the main object as generated by L2S, the namespaces are the same. Any ideas as to what i might be doing wrong?
I realize that the .NET RIA services is still CTP, but this seems like a fundamental part of the framework that should be working.