New Posts New Posts RSS Feed: OData and CodeFirst
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

OData and CodeFirst

 Post Reply Post Reply
Author
cseils View Drop Down
Newbie
Newbie
Avatar

Joined: 29-Mar-2011
Location: Australia
Posts: 10
Post Options Post Options   Quote cseils Quote  Post ReplyReply Direct Link To This Post Topic: OData and CodeFirst
    Posted: 30-Jan-2012 at 7:53pm
Thanks Silvio, I tried this out and it all works.
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 30-Jan-2012 at 12:54pm
Hi cseils,
 
Yes, it is possible to enable OData and use Code First entities.
Be sure to decorate your Code First entities with the IgnoreProperties and DataServiceKey attributes:
 
[IgnoreProperties(@"EntityAspect", @"AAAA_EntityAspectForSerialization")]
[DataServiceKey(@"MyEntityID")] // where MyEntityID is the entity's key
 
Other than that, you will need to follow steps 2 and 3 described in the  Enabling OData topic in the DevForce Resource Center.
Also, you might want to implement System.Data.Services.IUpdatable to support OData updates.
 
Regards,
   Silvio.
Back to Top
cseils View Drop Down
Newbie
Newbie
Avatar

Joined: 29-Mar-2011
Location: Australia
Posts: 10
Post Options Post Options   Quote cseils Quote  Post ReplyReply Direct Link To This Post Posted: 29-Jan-2012 at 9:05pm
Is it possible to enable OData with an entity model created using the Code First method.
I can't see anything in the documentation other that enabling OData using the Model or Database First method.

Thanks
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down