Not loading the object caused EF4 (code first) to remove the relationship
Posted
by
Lavinski
on Stack Overflow
See other posts from Stack Overflow
or by Lavinski
Published on 2011-06-27T12:20:00Z
Indexed on
2011/06/27
16:22 UTC
Read the original article
Hit count: 211
Firstly this is a EF4: Code First - Property Loading question.
I'm loading an object like so
var item = Context.Table.Find( update.Identifier );
This object has a property Relationship
so a table has a Relationship
object.
Now i'm updating my item but my Relationship
object is not toched (and therefore not lazy loaded).
Now here's the problem ..
I save my item and my relationship to the Relationship
object is deleted, apparently the model thinks i set it to null. However it all works if I look at the property before saving.
So I'm looking into LoadProperty
or doing a query and using Include
.
Has anyone else come across this issue and how did you get around it?
© Stack Overflow or respective owner