Print Page | Close Window

OData versus 'EntityState'

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3445
Printed Date: 13-May-2026 at 5:42am


Topic: OData versus 'EntityState'
Posted By: TonyHansen
Subject: OData versus 'EntityState'
Date Posted: 18-May-2012 at 11:39pm
I've enabled OData as described here:
http://drc.ideablade.com/xwiki/bin/view/Documentation/odata-enable - http://drc.ideablade.com/xwiki/bin/view/Documentation/odata-enable
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:
http://blogs.msdn.com/b/phaniraj/archive/2008/06/18/debugging-ado-net-data-services.aspx - http://blogs.msdn.com/b/phaniraj/archive/2008/06/18/debugging-ado-net-data-services.aspx
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



Replies:
Posted By: DenisK
Date 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 - 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#H233Moveyourcustomgeneratortoitsownassembly - 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 - uploads/912/ODataTour_WithCodeFirst.zip


Posted By: TonyHansen
Date 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



Print Page | Close Window