It depends whether you are using independent or foreign key associations.
For independent associations - these are associations that don't have the foreign key as a property in your model, but only the navigation property - nothing will happen with the navigation properties and foreign key values in the database if you set the state to Modified
. They remain unchanged because the generated UPDATE statement won't include a change of the FK column value. It's by the way also the case if the navigation property is not null
. Setting the entity state to Modified
does not affect navigation properties, only scalar properties.
If you have foreign key associations - associations that have the foreign key as a property in your model - setting the state to Modified
will mark the foreign key property as Modified
because it is a scalar property. As a result the current FK property value will be written to the database and possibly change a relationship there, even if the navigation property is null
.