Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7674615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:46:39+00:00 2026-05-31T16:46:39+00:00

This is a simplified version of the problem I am trying to solve: There

  • 0

This is a simplified version of the problem I am trying to solve:

There are two entities:

Item

ItemID (PK)

Other simple properties…

WorkItem (navigation property)

WorkItem

ItemID (PK)

Other Simple Properties…

Item (Navigation property)

 


I need to create an Item, a WorkItem for it and I need to set both the navigation properties so the the two entities can point to each other, before saving.

This I can do:

  Item newItem = Item.CreateItem(0, blah,blah,blah);
  service.AddToItems(newItem);


  WorkItem newWorkItem = new WorkItem();           
  service.AddToWorkItems(newWorkItem);

  //set the navigation properties
  newItem.WorkItem = newWorkItem;
  newWorkItem.Item = newItem;

Unfortunately, when it comes to saving, this fails. I believe EF, when trying to set WorkItem’s Item association, tries to set WorkItem’s primary key.

Can anybody enlighten me as to the correct way to achieve this please?



 
Update:
 
 
So, I have tried building the model using inheritance. The model builds and validates.

Unfortunately, adding a WCF Data Service for my model and trying to view the service in a browser gives me this:

  ..... <m:message xml:lang="en-US">An error occurred while processing this request.    </m:message>
<m:innererror>
  <m:message>Navigation Properties are not supported on derived entity types. Entity Set 'app_Items' has a instance of type 'tempmodel.app_CostItem', which is an derived entity type and has navigation properties. Please remove all the navigation properties from type 'tempmodel.app_CostItem'.</m:message>
  <m:type>System.InvalidOperationException</m:type>
  <m:stacktrace>   at System.Data.Services.Serializers.SyndicationSerializer.WriteObjectProperties(IExpandedResult expanded, ......

CostItem being another entity, like WorkItem, which derives from Item.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:46:40+00:00Added an answer on May 31, 2026 at 4:46 pm

    I eneded up creating a dummy property in each of my client side partial “sub”-classes:

        private Item _BaseItem;
        [AtomIgnore]
        internal Item BaseItem
            {
            get
                {
                if (_BaseItem != null)
                    return _BaseItem;
                else
                    return this.Item;                
                }
            set
                {
                _BaseItem = value;
                OnPropertyChanged("Item");
                }
            }
    

    Code on the client side uses this BaseItem property to traverse the object graph in reverse. So the code to set up the relationships now looks like this:

     Item newItem = Item.CreateItem(0, blah,blah,blah);
     service.AddToItems(newItem);
    
    
     WorkItem newWorkItem = new WorkItem();           
     service.AddToWorkItems(newWorkItem);
    
     //set the navigation properties
     newItem.WorkItem = newWorkItem;
     newWorkItem.**BaseItem** = newItem;
    

    Note, the BaseItem property is declared internal; this is so that the serialiser will not attempt to serialise the property and send it to the server.

    [AtomIgnore] is an attribute I created and look for in my handler for DataServiceContext.WritingEntity. The handler strips out properties marked with this attribute before they are sent to the server. This technique doesn’t seem to work if the property is a ref type though, hence the use of internal.

    Declaring it internal also means it cannot be bound to from XAML, fortunately i only needed to bind to a couple of properties so that work around was straightforward.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is the simplified version of my problem: I'm trying to extract all letters
In this simplified version of my actual problem, I have two tables: User and
This is a simplified version of the original problem. I have a class called
This application is a much simplified version of what I am trying to accomplish,
I have two data structure classes (this is a simplified version of my code)
I have a multi-table query, similar to this (simplified version) SELECT columns, count(table2.rev_id) As
This is a simplified partial version of my code to demonstrate the issue: function
This is a (very) simplified version of my iPhone code : @interface x {
Imagine this simplified markup: <div id=header> <!-- Other things.... --> <div id=detail> </div> </div>
I'm starting out with some XML that looks like this (simplified): <?xml version=1.0 encoding=UTF-8?>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.