New Posts New Posts RSS Feed: OData versus 'EntityState'
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

OData versus 'EntityState'

 Post Reply Post Reply
Author
TonyHansen View Drop Down
Newbie
Newbie


Joined: 18-May-2012
Location: Adelaide
Posts: 7
Post Options Post Options   Quote TonyHansen Quote  Post ReplyReply Direct Link To This Post Topic: OData versus 'EntityState'
    Posted: 21-May-2012 at 7:47pm
Thanks for your assistance!
 
I started off following the video for Code Second to generate against a basic database I had already setup.  Rather than building a Silverlight app, I have been attempting to build a Winforms n-tier app. 
 
Ran into stacks of problems with missing references etc, managed to solve all those, but then got stuck on the EntityState problem (which looks to have a resolution), so thought I'd switch to looking at OData ... and hit a wall there as well.
 
Just like me to start breaking things my first time out! :-D
 
I'll implement your suggestion this evening, and give it another shot.  Again, thanks for your assistance!
 
T
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 21-May-2012 at 3:09pm
Hi TonyHansen,

I was able to reproduce the issue here. I'm assuming you're using Code First entities with "Code Second" method of template generation per your post here. http://www.ideablade.com/forum/forum_posts.asp?TID=3446&PID=13611&title=entitystate-property-not-available#13611

If so, this is a bug specific to using Code First. I'll file a bug report. For now, the workaround is to add the following property to your IgnorePropertiesAttribute as follows.

[IgnoreProperties(@"EntityAspect", @"AAAA_EntityAspectForSerialization")]

If you have many entities, you can customize the T4 template so you don't have to manually write the above. http://drc.ideablade.com/xwiki/bin/view/Documentation/custom-code-generation-template

I've modified our current OData tour sample so that it uses Code Second and a custom T4 template in its own assembly. You can download it here. uploads/912/ODataTour_WithCodeFirst.zip
Back to Top
TonyHansen View Drop Down
Newbie
Newbie


Joined: 18-May-2012
Location: Adelaide
Posts: 7
Post Options Post Options   Quote TonyHansen Quote  Post ReplyReply Direct Link To This Post Posted: 18-May-2012 at 11:39pm
I've enabled OData as described here:
I've ended up with the cursed "An error occurred while processing this request." error. I then Googled around until I found out how to turn on debugging, as per the instructions here:
Now I'm seeing that the cause of the problem is an 'EntityState' property:
<SNIP>
The server encountered an error processing the request. The exception message is 'The property 'EntityState' on type 'IdeaBlade.EntityModel.EntityAspect' is not a valid property. Make sure that the type of the property is a public type and a supported primitive type or a entity type with a valid key or a complex type.'.
</SNIP>
Doing a search over my code, I can't even find an 'EntityState' property, leading me to think this is an internal DevForce property.
So ... what causes this, and how do I either fix it, or work around it?
Environment is Visual Studio 11 Beta, .NET Framework 4 project, on Win7 Ultimate.
Any assistance appreciated!
T
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down