<?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 : Bug in using AttachEntity and Navigation Property.</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Bug in using AttachEntity and Navigation Property.</description>
  <pubDate>Wed, 13 May 2026 05:44:40 -700</pubDate>
  <lastBuildDate>Tue, 22 May 2012 00:56:44 -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=3417</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>Bug in using AttachEntity and Navigation Property. : Nice,Thanks for the feedback. </title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3417&amp;PID=13626#13626</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=998" rel="nofollow">Walid</a><br /><strong>Subject:</strong> 3417<br /><strong>Posted:</strong> 22-May-2012 at 12:56am<br /><br />Nice,<div><br></div><div>Thanks for the feedback.</div>]]>
   </description>
   <pubDate>Tue, 22 May 2012 00:56:44 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3417&amp;PID=13626#13626</guid>
  </item> 
  <item>
   <title>Bug in using AttachEntity and Navigation Property. : Hi Walid,Just want to let you...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3417&amp;PID=13612#13612</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=912" rel="nofollow">DenisK</a><br /><strong>Subject:</strong> 3417<br /><strong>Posted:</strong> 21-May-2012 at 12:29pm<br /><br />Hi Walid,<div><br></div><div>Just want to let you know that the AttachEntity bug as you reported above has been fixed. It'll be included in the next release.</div>]]>
   </description>
   <pubDate>Mon, 21 May 2012 12:29:43 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3417&amp;PID=13612#13612</guid>
  </item> 
  <item>
   <title>Bug in using AttachEntity and Navigation Property. : Hi Walid,Thanks for pointing out...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3417&amp;PID=13490#13490</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=912" rel="nofollow">DenisK</a><br /><strong>Subject:</strong> 3417<br /><strong>Posted:</strong> 03-May-2012 at 4:20pm<br /><br />Hi Walid,<div><br></div><div>Thanks for pointing out that possible bug. Let me find out whether it's a real bug and file a report as necessary.</div><div><br></div><div>For now, I'm suggesting to use the first workaround with the addition of calling AcceptChanges on the entity.</div><div><br></div><div><table width="99%"><tr><td><pre class="BBcode"></div><div><div>&nbsp; &nbsp; &nbsp;var manager = new TestEntities();</div><div><br></div><div>&nbsp; &nbsp; &nbsp; var profession = new Profession() {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; Id = 1,</div><div>&nbsp; &nbsp; &nbsp; &nbsp; Title = "Boss",</div><div>&nbsp; &nbsp; &nbsp; };</div><div>&nbsp; &nbsp; &nbsp; if (attachProfession)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; manager.AttachEntity(profession);</div><div><br></div><div>&nbsp; &nbsp; &nbsp; var user = new User {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; Id = 2,</div><div>&nbsp; &nbsp; &nbsp; &nbsp; Name = "User test with Profession",</div><div>&nbsp; &nbsp; &nbsp; };</div><div><br></div><div>&nbsp; &nbsp; &nbsp; manager.AttachEntity(user);</div><div>&nbsp; &nbsp; &nbsp; user.Profession = profession;</div><div><br></div><div>&nbsp; &nbsp; &nbsp; //Call AcceptChanges to make the user's state change from Modified to Unchanged</div><div>&nbsp; &nbsp; &nbsp; EntityAspect.Wrap(user).AcceptChanges();</div></div><div></pre></td></tr></table></div><div><br></div><div>Please let me know if this works for you or not.</div>]]>
   </description>
   <pubDate>Thu, 03 May 2012 16:20:31 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3417&amp;PID=13490#13490</guid>
  </item> 
  <item>
   <title>Bug in using AttachEntity and Navigation Property. : There is another problem. I made...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3417&amp;PID=13472#13472</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=998" rel="nofollow">Walid</a><br /><strong>Subject:</strong> 3417<br /><strong>Posted:</strong> 02-May-2012 at 3:36am<br /><br /><div><div>There is another problem. I made a function which &nbsp;first create all the entities and set all the navigation properties, then attach them to the manager.</div><div><br></div><div>The Navigation properties are correctly set but all the foreignkey are set to 0.&nbsp;</div><div>Note : AddEntities does correctly update the foreignKey;<br><div><br></div><div><br></div><div><pre style="font-family: C&#111;nsolas; font-size: 13px; -: initial; -attachment: initial; -origin: initial; -clip: initial; : white; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">private</span>&nbsp;<span style="color: blue; ">static</span>&nbsp;<span style="color: blue; ">void</span>&nbsp;Test4()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">var</span>&nbsp;manager&nbsp;=&nbsp;<span style="color: blue; ">new</span>&nbsp;<span style="color: rgb43, 145, 175; ">TestEntities</span>(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">var</span>&nbsp;professions&nbsp;=&nbsp;<span style="color: blue; ">new</span>&nbsp;<span style="color: rgb43, 145, 175; ">List</span>&lt;<span style="color: rgb43, 145, 175; ">Profession</span>&gt;()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">new</span>&nbsp;<span style="color: rgb43, 145, 175; ">Profession</span>()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb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bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">var</span>&nbsp;users&nbsp;=&nbsp;<span style="color: blue; ">new</span>&nbsp;<span style="color: rgb43, 145, 175; ">List</span>&lt;<span style="color: rgb43, 145, 175; ">User</span>&gt;()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">new</span>&nbsp;<span style="color: rgb43, 145, 175; ">User</span>()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n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">"User&nbsp;2"</span>,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Profession&nbsp;=&nbsp;professions&#091;1&#093;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;manager.AttachEntities(professions);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;manager.AttachEntities(users); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">foreach</span>&nbsp;(<span style="color: blue; ">var</span>&nbsp;user&nbsp;<span style="color: blue; ">in</span>&nbsp;users)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: green; ">//&nbsp;Navigation&nbsp;property&nbsp;is&nbsp;correctly&nbsp;set</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgb43, 145, 175; ">Debug</span>.Assert(!<span style="color: rgb43, 145, 175; ">EntityAspect</span>.Wrap(user.Profession).IsNullOrPendingEntity);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: green; ">//&nbsp;The&nbsp;foreignkey&nbsp;isn't&nbsp;set</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgb43, 145, 175; ">Debug</span>.Assert(user.ProfessionId&nbsp;==&nbsp;0);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</pre></div><div><br></div><div><br></div><br ="Apple-interchange-newline"></div></div>]]>
   </description>
   <pubDate>Wed, 02 May 2012 03:36:01 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3417&amp;PID=13472#13472</guid>
  </item> 
  <item>
   <title>Bug in using AttachEntity and Navigation Property. : Hi Denis, Thanks but only one...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3417&amp;PID=13471#13471</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=998" rel="nofollow">Walid</a><br /><strong>Subject:</strong> 3417<br /><strong>Posted:</strong> 02-May-2012 at 12:48am<br /><br /><p>Hi Denis,</p><div> </div><div>Thanks but only one of those workaround works and it isn't always applicable.</div><div>The workaround where we attach first then set the navigation property change the entitystate of the entity which is not what we want (or we would have use AddEntity).</div><div>&nbsp;</div><div>In fact, what you said earlier is what is happening. Setting a navigation property to an already attached/added entity will add the entity to the EM and set the auto generated Id. Attaching isn't the real cause.</div><div>&nbsp;</div><div>The workaround where I attach all the entities in last (after all the settings is done) might not be applicable in some case. Sometimes, the entity I want to use for my navigation property been attached "somewhere else".</div><div>How can I deal with this issue in an elegant way ? Attaching, changing back the Id, updating the entitystate doesn't sound like a solution to me when you have to deal with hundreds of entities.</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div><div><div>This exemple show AttachEntity isn"'t the real problem. </div><div><pre style="color: black; font-family: C&#111;nsolas;">        <span style="color: blue;">var</span> profession = <span style="color: blue;">new</span> <span>Profession</span>()        {            Id = 1,            Title = <span>"Boss"</span>,        };        manager.AttachEntity(profession); </pre><pre style="color: black; font-family: C&#111;nsolas;">         <span style="color: blue;">var</span> user = <span style="color: blue;">new</span> <span>User</span>        {            Id = 2,            Name = <span>"User test with Profession"</span>,        };         user.Profession = profession;        <span>Debug</span>.Assert(user.Id == 2, <span style="color: blue;">string</span>.Format(<span>"Id expected = 2 - Id current value = </span><span style="color: mediumseagreen;">{0}</span><span> "</span>, user.Id));</pre></div><div> </div><div>&nbsp;</div></div>]]>
   </description>
   <pubDate>Wed, 02 May 2012 00:48:27 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3417&amp;PID=13471#13471</guid>
  </item> 
  <item>
   <title>Bug in using AttachEntity and Navigation Property. :  Hi Walid,Not sure what happened...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3417&amp;PID=13469#13469</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=912" rel="nofollow">DenisK</a><br /><strong>Subject:</strong> 3417<br /><strong>Posted:</strong> 01-May-2012 at 6:39pm<br /><br />Hi Walid,<div><br></div><div>Not sure what happened but I can finally see the assert failed. I've modified the solution and added some comments to illustrate the correct way to achieve what you want.</div><div><br></div><div><a href="uploads/912/C&#111;nsoleApplicati&#111;n3_Modified.zip" target="_blank">uploads/912/ConsoleApplication3_Modified.zip</a><br></div>]]>
   </description>
   <pubDate>Tue, 01 May 2012 18:39:45 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3417&amp;PID=13469#13469</guid>
  </item> 
  <item>
   <title>Bug in using AttachEntity and Navigation Property. : Strange, the assert fail each...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3417&amp;PID=13463#13463</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=998" rel="nofollow">Walid</a><br /><strong>Subject:</strong> 3417<br /><strong>Posted:</strong> 01-May-2012 at 1:32am<br /><br />Strange, the assert fail each time for me.&nbsp;<div>i am using Devforce 6.1.6 and EntityFramework 4.3.1<div><br>&nbsp;<div><br></div><div><img src="uploads/998/01-05-2012_10-48-16.png" height="833" width="912" border="0" /><br></div></div></div><span style="font-size:10px"><br /><br />Edited by Walid - 01-May-2012 at 1:49am</span>]]>
   </description>
   <pubDate>Tue, 01 May 2012 01:32:01 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3417&amp;PID=13463#13463</guid>
  </item> 
  <item>
   <title>Bug in using AttachEntity and Navigation Property. : Hi Walid,My apologies, but you&amp;#039;re...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3417&amp;PID=13461#13461</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=912" rel="nofollow">DenisK</a><br /><strong>Subject:</strong> 3417<br /><strong>Posted:</strong> 30-Apr-2012 at 5:36pm<br /><br />Hi Walid,<div><br></div><div>My apologies, but you're correct. AttachEntity is NOT the same as AddEntity. Our DRC says,</div><div><br></div><div>"theEntity’s EntityKey (“the key”) must be preset prior to the attach operation (which will not touch the key)."</div><div><br></div><div>which confirms what you said above.</div><div><br></div><div>Now with this said, I just ran your sample and I don't see user.Id changes to -100. It stayed at 2 in both cases.</div>]]>
   </description>
   <pubDate>Mon, 30 Apr 2012 17:36:23 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3417&amp;PID=13461#13461</guid>
  </item> 
  <item>
   <title>Bug in using AttachEntity and Navigation Property. : hi Denis,thanks, i thought attach...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3417&amp;PID=13460#13460</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=998" rel="nofollow">Walid</a><br /><strong>Subject:</strong> 3417<br /><strong>Posted:</strong> 30-Apr-2012 at 4:47pm<br /><br />hi Denis,<div><br></div><div>thanks, i thought attach doesn't touch the key, but only add it in the unchanged state.<br><div><br></div><div>so the "best practice" is to attach an entity right after it has been created and to set the navigation properties in last.</div></div>]]>
   </description>
   <pubDate>Mon, 30 Apr 2012 16:47:47 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3417&amp;PID=13460#13460</guid>
  </item> 
  <item>
   <title>Bug in using AttachEntity and Navigation Property. : Hi Walid,By default, User.Id and...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3417&amp;PID=13459#13459</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=912" rel="nofollow">DenisK</a><br /><strong>Subject:</strong> 3417<br /><strong>Posted:</strong> 30-Apr-2012 at 4:35pm<br /><br />Hi Walid,<div><br></div><div>By default, User.Id and Profession.Id are Identity columns when doing Code First unless you specify it otherwise by marking it as such.</div><div><br></div><div>&#091;DatabaseGenerated(System.ComponentModel.DataAnnotations.DatabaseGeneratedOption.None)&#093;</div><div><br></div><div>An identity column/id will be assigned a new temporary id as soon as it is attached or added to the EntityManager. In your "what doesn't work" scenario, when you create a User with Id 1, it is still unattached. But as soon as you're setting its User.Profession property to an already attached/added Profession entity, the unattached User will be attached and its Id will automatically be set to a temp Id overwriting whatever Id it was set to.</div>]]>
   </description>
   <pubDate>Mon, 30 Apr 2012 16:35:58 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3417&amp;PID=13459#13459</guid>
  </item> 
  <item>
   <title>Bug in using AttachEntity and Navigation Property. : Hi,Currently working with AttachEntity...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3417&amp;PID=13456#13456</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=998" rel="nofollow">Walid</a><br /><strong>Subject:</strong> 3417<br /><strong>Posted:</strong> 30-Apr-2012 at 10:41am<br /><br />Hi,<div><br></div><div>Currently working with AttachEntity for the Faking (faking isn't relevant in this case), I have a strange behavior when I set a navigation property.</div><div><br></div><div>Considering those 2 entities :</div><div><br></div><div><pre style="font-family: C&#111;nsolas; font-size: 13px; -: initial; -attachment: initial; -origin: initial; -clip: initial; : white; ">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">public</span>&nbsp;<span style="color: blue; ">class</span>&nbsp;<span style="color: rgb43, 145, 175; ">User</span>&nbsp;:&nbsp;<span style="color: rgb43, 145, 175; ">BaseEntity</span>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#091;<span style="color: rgb43, 145, 175; ">Key</span>&#093;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">public</span>&nbsp;<span style="color: blue; ">int</span>&nbsp;Id&nbsp;{&nbsp;<span style="color: blue; ">get</span>;&nbsp;<span style="color: blue; ">set</span>;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">public</span>&nbsp;<span style="color: blue; ">string</span>&nbsp;Name&nbsp;{&nbsp;<span style="color: blue; ">get</span>;&nbsp;<span style="color: blue; ">set</span>;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#091;<span style="color: rgb43, 145, 175; ">ForeignKey</span>(<span style="color: rgb163, 21, 21; ">"Profession"</span>)&#093;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">public</span>&nbsp;<span style="color: blue; ">int</span>&nbsp;ProfessionId&nbsp;{&nbsp;<span style="color: blue; ">get</span>;&nbsp;<span style="color: blue; ">set</span>;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">public</span>&nbsp;<span style="color: rgb43, 145, 175; ">Profession</span>&nbsp;Profession&nbsp;{&nbsp;<span style="color: blue; ">get</span>;&nbsp;<span style="color: blue; ">set</span>;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">public</span>&nbsp;<span style="color: blue; ">class</span>&nbsp;<span style="color: rgb43, 145, 175; ">Profession</span>&nbsp;:&nbsp;<span style="color: rgb43, 145, 175; ">BaseEntity</span>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#091;<span style="color: rgb43, 145, 175; ">Key</span>&#093;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">public</span>&nbsp;<span style="color: blue; ">int</span>&nbsp;Id&nbsp;{&nbsp;<span style="color: blue; ">get</span>;&nbsp;<span style="color: blue; ">set</span>;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#091;<span style="color: rgb43, 145, 175; ">Required</span>&#093;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">public</span>&nbsp;<span style="color: blue; ">string</span>&nbsp;Title&nbsp;{&nbsp;<span style="color: blue; ">get</span>;&nbsp;<span style="color: blue; ">set</span>;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;}</pre></div><div><br></div><div>What works :</div><div>1 - I create a Profession with Id 1 and&nbsp;<b>DOESN'T&nbsp;attach</b>&nbsp;it to the manager.</div><div>2 - I create a user with Id 1 and set the Profession to the User</div><div><b><font color="#006600">=&gt; &nbsp;user.Id == 1</font></b></div><div><br></div><div>What doesn't work :</div><div><div>1 - I create a Profession with Id 1 and&nbsp;<b>attach&nbsp;</b>it to the manager.</div><div>2 - I create a user with Id 1 and set the Profession to the user</div><div><font color="#ff0000"><b>=&gt; user.Id == -100</b></font></div><div><br></div><div><br></div><div>Here is a test &nbsp;application&nbsp;<a href="http://www.ideablade.com/forum/uploads/998/C&#111;nsoleApplicati&#111;n3.zip" target="_blank">uploads/998/ConsoleApplication3.zip</a></div><br ="Apple-interchange-newline"></div><br ="Apple-interchange-newline">]]>
   </description>
   <pubDate>Mon, 30 Apr 2012 10:41:08 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3417&amp;PID=13456#13456</guid>
  </item> 
 </channel>
</rss>