title: EF oData - element type is not an entity type
body: <p>I'm trying to get an odata demo up and running at the moment, but I'm seeing this error:</p>
  
  <blockquote>
    <p>'On data context type 'TweetPicContext', there is a top IQueryable
    property 'Users' whose element type is not an entity type. Make sure
    that the IQueryable property is of entity type or specify the
    IgnoreProperties attribute on the data context type to ignore this
    property.</p>
  </blockquote>
  
  <p>The annoying thing is that my code is pretty much a cut and paste of an existing project - but obviously something is going wrong...</p>
  
  <p>Looking at previous questions/answers the common answer seems to be the <code>DataServiceKey</code> attribute - but I'm already using that.</p>
  
  <p>Anyone got any ideas where I'm going wrong?</p>
  
  <p>This is my data context:</p>
  
  <pre><code>public class TweetPicContext : DbContext
  {
      public DbSet&lt;User&gt; Users { get; set; }
      public DbSet&lt;Picture&gt; Pictures { get; set; }
  }
  </code></pre>
  
  <p>This is my user data class:</p>
  
  <pre><code>[DataServiceKey("UserID")]
  public class User
  {
      [Key]
      public int UserID { get; set; }
  
      public string Name { get; set; }
      public string TwitterHandle { get; set; }
      public string TwitterIconUrl { get; set; }
      public int TwitterId { get; set; }
      public string TwitterAuthorizationToken { get; set; }
      public string TwitterAuthorizationTokenSecret { get; set; }
      public DateTime DateJoinedUtc { get; set; }
      public string UniqueDeviceToken { get; set; }
  
      public virtual ICollection&lt;Picture&gt; Pictures { get; set; } 
  
      public User()
      {
          DateJoinedUtc = DateTime.UtcNow;
          UniqueDeviceToken = Guid.NewGuid().ToString("N");
      }
  }
  </code></pre>
  
  <p>This is my user service:</p>
  
  <pre><code>[ServiceBehavior(IncludeExceptionDetailInFaults = true)]
  public class TweetPicOData : DataService&lt;TweetPicContext&gt;
  {
      // This method is called only once to initialize service-wide policies.
      public static void InitializeService(IDataServiceConfiguration config)
      {
          config.SetEntitySetAccessRule("Users", EntitySetRights.AllRead);
          config.SetEntitySetAccessRule("Pictures", EntitySetRights.AllRead);
          config.UseVerboseErrors = true;
      }
  
      // see http://romiller.com/2010/07/19/ef-ctp4-tips-tricks-wcf-data-service-on-dbcontext/
      protected override TweetPicContext CreateDataSource()
      {
          var ctx = base.CreateDataSource();
  
          // Disable proxy object creation.
          ctx.Configuration.ProxyCreationEnabled = false;
          return ctx;
      }
  }
  </code></pre>