Using Entity Framework and having the following class:
public class TestClass{
[Key]
public int id {get; set;}
public int foreignId {get; set;}
[ForeignKey("foreignId")
public MyObject myObject {get; set;}
}
With this class I want to save the "TestClass" but the entity framework first tries to save/create the "myObject" that doesn't need to get saved because it's only a reference. In some forums (enter link description here) I read that I has to set the myObject explicitely to "null" before saving, but in my opinition this is quite annoying.
So I want to ask if there is any annotation or something like "IgnoreOnSave" that I can add to the myObject?
[ForeignKey("foreignId", "ignoreOnSave")]
public MyObject myObject {get; set;}