Switching from Linq-To-SQL to Entity Framework for WCF Data Services Issue with FK "Properties"

Someone asked on Stack Overflow:

So, In my old Linq-To-SQL I would write code like this

var tableItem = new Table
{
    Prop1 = var1
    Prop2 = var2,
    Prop3 = var3,
    ParentTableID = parentRecordID
};

db.Table.InsertOnSubmit(tableItem);
db.SubmitChanges();

After converting my working code from Linq-To-SQL to Entity Framework (v3.5) the ParentTableID property is no longer there and I’m at a loss as to how I can create this related child record.

I’m not sure what I should change for my entity framework version, besides the obvious call to SaveChanges(); instead of SubmitChanges() :(

I posted the following answer, which was chosen as the accepted answer:

I ended up using the solution here: Entity Framework: Setting a Foreign Key Property.


Originally posted on Stack Overflow — 0 upvotes (accepted answer). Licensed under CC BY-SA.

signed letter b

Dad. Geek. Gamer. Software developer. Cloud user. Old Car enthusiast.  Blogger.


Top Posts


profile for Nate on Stack Exchange, a network of free, community-driven Q&A sites
a proud member of the blue team of 512KB club
Thoughts, opinions, and ideas shared here are my own. © 2026 Nate Bross.