Ado.net entity framework and linq to entities https: first of all you cannot update the foreign keys in an entity--they are read-only. you must update the whole entity. my guess is that this approach keeps the data in the enties in the project exactly as what's in the database--a good thing.. Synchronizing the changes between the foreign keys and navigation properties. when you change the relationship of the objects attached to the context by using one of the methods described above, entity framework needs to keep foreign keys, references, and collections in sync.. If so, i am confused why the foreign key is not changed at your side and you could copy the code above and just replace my entities with yours to see whether it would work. or you could try to assign the foreign key value to the foreign key property as: orderdnew.orderid = db.orders.find(2).orderid;.
Dependent entity: this is the entity that contains the foreign key property(s). sometimes referred to as the 'child' of the relationship. sometimes referred to as the 'child' of the relationship. principal entity: this is the entity that contains the primary/alternate key property(s).. In version 1, entity framework can't work with just foreign key values being inserted - you'll need to add the "category" object instance to the "appuser"'s cateogry navigation property: //create entity with passed values appuser user = new appuser(){uid=id,.. For most relationships, this can be done by updating either foreign key fields or navigation properties. for many-to-many relationships, the entity framework doesn't expose the join table directly, so you add and remove entities to and from the appropriate navigation properties..
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.