0

I have to down grade my app from .net 4 to 3.5 to get it to run on our server. :(

Anyway EF "Independent Association" - http://blogs.msdn.com/b/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx

...but now I can't figure out how to set the value of a foreign key because it no longer appears in my Entity.

Can anyone advise how I can do this please?

Positonic
  • 9,151
  • 14
  • 57
  • 84
  • possible duplicate http://stackoverflow.com/questions/480872/entity-framework-setting-a-foreign-key-property – moi_meme Sep 27 '11 at 16:58

1 Answers1

0

AFAIK, you cannot set the value directly, but must use the navigation property instead. So if you have a Parent row you would like to set the foreign key of to 15, it would look like this:

var Child = (from c in context.Children
             where id = 15).Single();
Parent.Child = Child;
context.SaveChanges();
therealmitchconnors
  • 2,732
  • 1
  • 18
  • 36