Export (0) Print
Expand All

How to: Use an EntityReference to Change Relationships Between Objects

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

This topic shows how to use the EntityReference object to change a relationship between two objects in the object context. When the SaveChanges method is called, the relationship change is persisted to the database as a change to the foreign key in the related table. For more information, see How to: Execute Business Logic During Association Changes.

The example in this topic is based on the Adventure Works Sales Model. To run the code in this topic, you must have already added the Adventure Works Sales Model to your project and configured your project to use the Entity Framework. For more information, see How to: Use the Entity Data Model Wizard (Entity Framework) or How to: Manually Configure an Entity Framework Project and How to: Manually Define an Entity Data Model (Entity Framework).

Example

This example shows how to use the EntityReference object to change a relationship between a SalesOrderHeader object and a related Address object that represents the shipping address for the order.

See Also

Show:
© 2015 Microsoft