开发者

How do I update a foreign key relationship in entity framework 4?

I have an object called Account, which has a reference to a timezone through a foreign-key relationship. On the Account-object I can see the TimeZone_Fk_Id as well as the reference to both Account.TimeZone and Account.TimeZoneReference.

I am trying to update the foreign key relationship but I cannot figure out how. I have tried all sorts of thing开发者_如何学JAVAs. I have tried setting the TimeZone_Fk_Id directly, tried setting the Account.TimeZone to a new timezone, tried updating the entitykeys etc etc. But nothing seems to work. I don't get any exceptions, but when I check the timezone after I supposedly have changed it, it is still the old value.

Any help is greatly appreciated

thanks Thomas


Have you tried something like

Account account;
TimeZone timeZone;  
//Get account instance  
//Get timeZone instance to update  
account.TimeZone = timeZone;  
context.SaveChanges();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜