Update referenceI have a LastModified relationship between SiteUser and GroupPost entities (1..*)<br><br>I'm trying to update reference using code below<span style="width:100%"><br><br></span> <div style="text-align:left"> <div class=codeseg> <div class=codecontent> <p>using (myEntities ee = new myEntities())<br></p> <p>{</p> <div style="margin-left:40px;text-align:left">GroupPost post = (from posts in ee.GroupPost.Include(&quot;SiteUser&quot;)<br></div> <div style="text-align:left">                                 where posts.PostID == id<br>                                 select posts).First&lt;GroupPost&gt;();<br><br></div> <div style="margin-left:40px;text-align:left">SiteUser u = ee.SiteUser.First&lt;SiteUser&gt;(e =&gt; e.UserName == HttpContext.User.Identity.Name);</div> <div style="margin-left:40px;text-align:left"><br>post.SiteUser = u;                <br></div> <div style="text-align:left">          <br>     ee.SaveChanges();<br>}<br></div> <div style="text-align:left"><br></div></div></div></div><br><br>which throws an exception<br><span></span> <h2 style="font-weight:normal;font-style:italic"><font size=2>A relationship is being added or deleted from relationship set 'SiteUserGroupPost'. Given cardinality constraints, a corresponding 'GroupPost' must also be added or deleted.</font></h2>How can I bind one <span style="font-style:italic">existing </span>entity object to another <span style="font-style:italic">existing </span>object?<br>© 2009 Microsoft Corporation. All rights reserved.Wed, 10 Dec 2008 23:43:19 Z2d6a6eb3-44ae-4dec-ad50-8ccedc4f06b3http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/2d6a6eb3-44ae-4dec-ad50-8ccedc4f06b3#2d6a6eb3-44ae-4dec-ad50-8ccedc4f06b3http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/2d6a6eb3-44ae-4dec-ad50-8ccedc4f06b3#2d6a6eb3-44ae-4dec-ad50-8ccedc4f06b3lubeinhttp://social.msdn.microsoft.com/Profile/en-US/?user=lubeinUpdate referenceI have a LastModified relationship between SiteUser and GroupPost entities (1..*)<br><br>I'm trying to update reference using code below<span style="width:100%"><br><br></span> <div style="text-align:left"> <div class=codeseg> <div class=codecontent> <p>using (myEntities ee = new myEntities())<br></p> <p>{</p> <div style="margin-left:40px;text-align:left">GroupPost post = (from posts in ee.GroupPost.Include(&quot;SiteUser&quot;)<br></div> <div style="text-align:left">                                 where posts.PostID == id<br>                                 select posts).First&lt;GroupPost&gt;();<br><br></div> <div style="margin-left:40px;text-align:left">SiteUser u = ee.SiteUser.First&lt;SiteUser&gt;(e =&gt; e.UserName == HttpContext.User.Identity.Name);</div> <div style="margin-left:40px;text-align:left"><br>post.SiteUser = u;                <br></div> <div style="text-align:left">          <br>     ee.SaveChanges();<br>}<br></div> <div style="text-align:left"><br></div></div></div></div><br><br>which throws an exception<br><span></span> <h2 style="font-weight:normal;font-style:italic"><font size=2>A relationship is being added or deleted from relationship set 'SiteUserGroupPost'. Given cardinality constraints, a corresponding 'GroupPost' must also be added or deleted.</font></h2>How can I bind one <span style="font-style:italic">existing </span>entity object to another <span style="font-style:italic">existing </span>object?<br>Thu, 06 Mar 2008 22:56:58 Z2008-03-09T14:48:43Zhttp://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/2d6a6eb3-44ae-4dec-ad50-8ccedc4f06b3#7cbdf4af-1e0d-400a-b777-1e2b8c6ab524http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/2d6a6eb3-44ae-4dec-ad50-8ccedc4f06b3#7cbdf4af-1e0d-400a-b777-1e2b8c6ab524MatthieuMEZILhttp://social.msdn.microsoft.com/Profile/en-US/?user=MatthieuMEZILUpdate reference<p>Hello,</p> <p align=left>I don't understand. I did the same as you and I have no problem.</p> <p align=left><font face=Arial size=2></font> </p>Fri, 07 Mar 2008 09:17:01 Z2008-03-07T09:17:01Zhttp://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/2d6a6eb3-44ae-4dec-ad50-8ccedc4f06b3#1233a710-8216-4e51-9cdf-c3f902d0d26chttp://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/2d6a6eb3-44ae-4dec-ad50-8ccedc4f06b3#1233a710-8216-4e51-9cdf-c3f902d0d26clubeinhttp://social.msdn.microsoft.com/Profile/en-US/?user=lubeinUpdate referenceI've solved this problem. I changed SiteUser End multiplicity from 1 to 0..1.<br>Sun, 09 Mar 2008 14:47:51 Z2008-03-09T14:48:43Z