Updating foregn Key in Linq to sql http://forums.asp.net/t/1671565.aspx/1?Updating+foregn+Key+in+Linq+to+sql+Mon, 11 Apr 2011 05:37:39 -040016715654377898http://forums.asp.net/p/1671565/4377898.aspx/1?Updating+foregn+Key+in+Linq+to+sql+Updating foregn Key in Linq to sql <p>I have a simple 2 table relationship:</p> <p>&nbsp;</p> <p>table 'a' contains FK to table 'b'. Table b contains a fixed number of records. A record in table 'a' over time need to point to different&nbsp;</p> <p>records in table 'b'. I understand that in linq I cannot just chenge FK, I need to change the entity that it represents. So I do </p> <p>&nbsp;</p> <p>a.b_entity = db.bs.single(b =&gt; b.id == &lt;other id&gt; );</p> <p>&nbsp;</p> <p>&lt;other_id&gt; exists in database. It works exept for one minor thing, For some reason, LINQ replicated record in table b and assigns the id&nbsp;</p> <p>of the new record. I do not need to create a new record! I need Fk in 'a' to piont directly to the record I selected in b and not its copy. </p> <p>What am I doing wrong?</p> 2011-04-11T05:37:39-04:00