<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : Relationship Entities are Read-only</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2009 : Relationship Entities are Read-only</description>
  <pubDate>Fri, 17 Apr 2026 00:59:11 -700</pubDate>
  <lastBuildDate>Thu, 18 Sep 2008 02:31:33 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=939</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>Relationship Entities are Read-only : I used Option 2 as recommended,...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=939&amp;PID=3391#3391</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=370" rel="nofollow">sebma</a><br /><strong>Subject:</strong> 939<br /><strong>Posted:</strong> 18-Sep-2008 at 2:31am<br /><br />I used Option 2 as recommended, i.e. Added a new payload column to my linking entity (RelGroups) in database table, backed-up and removed my old edmx, re-generated the new edmx and then the domain model. Now I have access to RelGroups entity and could add new sub-group entity with the following sample codes:<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;/// &lt;summary&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;/// Use this factory method template to create new instances of this class<br />&nbsp;&nbsp;&nbsp;&nbsp;/// &lt;/summary&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;/// &lt;param name="manager"&gt;The DevForce EntityManager&lt;/param&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;/// &lt;param name="name"&gt;The name for the new group&lt;/param&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;/// &lt;param name="parent"&gt;The parent TrainingGroup&lt;/param&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;/// &lt;param name="childLevel"&gt;The child node level in the group tree (This is the new "payload column" for information only), will persist to RelGroups.ChildLevel.&lt;/param&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;/// &lt;returns&gt;&lt;/returns&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;public static TrainingGroup Create(EntityManager manager, string name, TrainingGroup parent, int childLevel) <br />&nbsp;&nbsp;&nbsp;&nbsp;{ <br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TrainingGroup newChildGroup = manager.CreateEntity&lt;TrainingGroup&gt;();<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // if this object type requires a unique id and you have implemented<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // the IIdGenerator interface implement the following line<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //manager.GenerateId(aTrainingGroup, // add id column here //);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Add custom code here<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newChildGroup.AddToManager();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newChildGroup.Name = name;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RelGroup rel = RelGroup.Create(manager, parent, newChildGroup, childLevel);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return newChildGroup;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />Thank-you Greg and IdeaBlade's excellent dev support! <br /><br />]]>
   </description>
   <pubDate>Thu, 18 Sep 2008 02:31:33 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=939&amp;PID=3391#3391</guid>
  </item> 
  <item>
   <title>Relationship Entities are Read-only : Sebma:  The Add() method on...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=939&amp;PID=3389#3389</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=4" rel="nofollow">GregD</a><br /><strong>Subject:</strong> 939<br /><strong>Posted:</strong> 17-Sep-2008 at 1:59pm<br /><br />Sebma:<DIV>&nbsp;</DIV><DIV>The Add() method on navigation properties is the one feature of the Entity Framework not currently supported by DevForce EF. This does not constitute a problem for one-to-many navigation properties, as simply adding the child and setting its foreign key to the appropriate parent will cause it to show up in the parent's list of children.&nbsp; </DIV><DIV>&nbsp;</DIV><DIV>It is, however, a problem with many-to-many associations&nbsp;where the linking entity has no "payload"; i.e., it has no&nbsp;properties other than the two foreign keys.&nbsp; This is the situation you have.&nbsp; The reason it is a problem is that, as you know, the Entity Framework does not expose the linking entity when it has no payload. You can't add a RelGroup because no such entity exists!</DIV><DIV>&nbsp;</DIV><DIV>We plan to implement support for Add() in a (soon) forthcoming release. For now your options are these:</DIV><DIV>&nbsp;</DIV><DIV>Option 1. Expose the linking entity so you have something to add to. The best way to see how to do this is to go through the following process with a scratch model against a simple scratch database:</DIV><DIV>&nbsp;</DIV><DIV>a. Create a linking entity with a payload column -- anything -- and generate an Entity Data Model from it. </DIV><DIV>b. Remove the payload column from the table and remove the corresponding property from the conceptual entity.&nbsp; </DIV><DIV>&nbsp;</DIV><DIV>The linking entity will remain exposed, with only its two foreign key columns. &#091;1&#093;</DIV><DIV>&nbsp;</DIV><DIV>Option 2. Add a payload column *permanently* to the linking entity (and update the model).&nbsp; This is the option we recommend, for a couple of reasons. First and foremost, it eliminates the somewhat painful reengineering that you'll have to undertake&nbsp;if you decide downstream that your linking entity really needs a payload (i.e., there's some piece of information&nbsp;you want to track about the association itself). We find that it is a very common occurrence for linking entities to evolve into entities that have importance in their own right and have to carry several pieces of information above and beyond the linking information itself.&nbsp; Secondly, the payload can be an arbitary,&nbsp;single-column foreign key: something we also like. That's probably the kind of key you have for your other entities, and it's nice to have all of your entities operate the same way with respect to the primary key.</DIV><DIV>&nbsp;</DIV><DIV>FYI, we'll still recommend Option 2 even after we support the Add() method. The Add() functionality won't eliminate the aggravating reengineering involved in adding a payload to a linking entity that started life without one.</DIV><DIV>&nbsp;</DIV><DIV>Regards,</DIV><DIV>Greg Dunn</DIV><DIV>IdeaBlade</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV><DIV>&#091;1&#093; As an aside, we recommend that you *always* make a backup of your EDMX before you do any twiddling of any sort,&nbsp;until you're&nbsp;*very* familiar with the operation you're about to perform. It's easy to get an EDMX hosed up in a way that's difficult to recover from unless you really know your way around.&nbsp;</DIV></DIV><DIV>&nbsp;</DIV>]]>
   </description>
   <pubDate>Wed, 17 Sep 2008 13:59:36 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=939&amp;PID=3389#3389</guid>
  </item> 
  <item>
   <title>Relationship Entities are Read-only : Hi all,  I have a typical object...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=939&amp;PID=3387#3387</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=370" rel="nofollow">sebma</a><br /><strong>Subject:</strong> 939<br /><strong>Posted:</strong> 17-Sep-2008 at 9:05am<br /><br />Hi all,<DIV>&nbsp;</DIV><DIV>I have a typical object hierarchical group structure in which a Group and have Sub-groups and so on.</DIV><DIV>I managed to mapped this recursive relationship&nbsp;table(RelGroups)&nbsp;for this&nbsp;database table (TrainingGroup):</DIV><DIV>&nbsp;</DIV><DIV>TrainingGroup</DIV><DIV>InternalId Name</DIV><DIV>======= ====</DIV><DIV>1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Root</DIV><DIV>2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GroupA</DIV><DIV>3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GroupB</DIV><DIV>&nbsp;</DIV><DIV>RelGroups</DIV><DIV>ParentId ChildId</DIV><DIV>====== =====</DIV><DIV>1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2</DIV><DIV>1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3</DIV><DIV>&nbsp;</DIV><DIV>On the edmx side, it also generated the relationship mapping and I named them as ParentGroups and ChildGroups of a TrainingGroup. (I attached the edmx as well)</DIV><DIV><a href="http://www.ideablade.com/forum/uploads/370/DataModelSkillC&#111;n_edmx.zip" target="_blank">uploads/370/DataModelSkillCon_edmx.zip</A></DIV><DIV>&nbsp;</DIV><DIV><DIV>From the above I can retrieve from EntityManager&nbsp;the Root instance having GroupA and GroupB as children instances.</DIV></DIV><DIV>&nbsp;</DIV><DIV>However, the DevForce EF&nbsp;generated domain model does not allow me to add/update/delete the ParentGroups or ChildGroups because they are read-only. See Create method below.</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;&nbsp;&nbsp; public static TrainingGroup Create(EntityManager manager, string name, TrainingGroup parent) <BR>&nbsp;&nbsp;&nbsp; { </DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TrainingGroup newChildGroup = manager.CreateEntity&lt;TrainingGroup&gt;();</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Add custom code here</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newChildGroup.AddToManager();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newChildGroup.Name = name;<BR><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newChildGroup.ParentGroups.Add(parent); // ERROR! ParentGroups is read-only<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parent.ChildGroups.Add(newChildGroup);&nbsp; // ERROR! ChildGroups is read-only</strong></DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return newChildGroup;<BR>&nbsp;&nbsp;&nbsp; }</DIV><DIV>&nbsp;</DIV><DIV>Is there anyway to&nbsp;create a new TrainingGroup&nbsp;instance and&nbsp;a new relationship (ParentGroup and ChildGroup) in one transaction as above? Right now I cannot because the relationship generated is read-only.</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-ansi-: EN-US; mso-fareast-: EN-US; mso-bidi-: AR-SA"><?: prefix = v ns = "urn:schemas-microsoft-com:vml" /><v:shape id=_x0000_t75 stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600"></v:shape></SPAN>&nbsp;</DIV>]]>
   </description>
   <pubDate>Wed, 17 Sep 2008 09:05:29 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=939&amp;PID=3387#3387</guid>
  </item> 
 </channel>
</rss>