title: .NET RIA Services: "Associated Metadata contains the following unknown properties or fields"
body: <p>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.</p>
  
  <p>When i tried to compile, i got this error:</p>
  
  <blockquote>
    <p>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</p>
  </blockquote>
  
  <p>So i added a metadata class for the Service object like so:</p>
  
  <pre><code>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;
          }
      }
  }
  </code></pre>
  
  <p>Now i get this error:</p>
  
  <blockquote>
    <p>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</p>
  </blockquote>
  
  <p>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?</p>
  
  <p>I realize that the .NET RIA services is still CTP, but this seems like a fundamental part of the framework that should be working.</p>