Geeks With Blogs

News
Step-by-Step into the cloud a blog of Dirk Eisenberg (>)

Just a second ago I tried to update my WCF data service. I wanted to expose a collection of the following class (This model is part of a hand made POCO set which is mapped to an E/F conceptional model):

 

class Car
{
  public int MyID { get; set; }
 
public string CarName { get; set; }
}

I got a service exception of course  and the exception message said something about that the element type of my cars collection is not an entity type. To solve this problem you have 2 options:

  1. Rename your MyID property to CarID or ID
  2. Set the IgnoreProperties-attribute from the entity framework

I prefered solutions one so my class was changed to the following structure:

public class Car
{

  public int ID { get; set; }
 
public string CarName { get; set; }
}

After that change everything worked fine, so keep in mind. The following implementation would also be possible:

public class Car
{

  public int CarID { get; set; }
 
public string CarName { get; set; }
}

public

Posted on Monday, January 10, 2011 1:10 AM .NET Coding , Coding , OData | Back to top


Comments on this post: Set the right names of the id attribute in the model classes of an OData service

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Dirk Eisenberg | Powered by: GeeksWithBlogs.net