I have code structure like that:
var adjective = context.Adjectives.Find(11); //works
var substantive = context.Substantives.Find(11); //works
var address = context.Addresses.Where(v => v.ZipCode == new_possible_address.ZipCode).SingleOrDefault(); //works
var name = context.Names.Find(91); //doesn't work
The last line shows the error message:
“The property ‘Id’ is part of the object’s key information and cannot
be modified.”
I’ve noted if I remove the Where statment, the last Find method works. So:
var adjective = context.Adjectives.Find(11); //works
var substantive = context.Substantives.Find(11); //works
var name = context.Names.Find(91); //now works
Also, if I use the debug feature “Set Next Statement” going to adjective or substantive lines right after the execution of “Addresses.Where” line. Both methods stops working too.
Why I can’t use Find and Where method within the same context?
It was a model problem. I had to complete a navigation mapping like that:
I needed just this way.