Is there an elegant way to save an entity without saving it's navigation properties?
I send an entity graph from web page to a Web API service. Since client doesn't have access to navigation properties, it sends data without those properties back to server. Once I mark the entity as State.Modified
, EF attempts to save relations also.
I'm going to try out following workflow, but don't like it very much:
- Load original entity from database
- Create generic method to copy all non-navigation properties from modified to original entity
- Properties with name ending in
Id
will not be copied over (since I have foreign-keys mapped also) - Save such entity
This is not very elegant. How would you do it?