title: Entity Framework Manage Runtime Object
body: <p>I´ve got a basic entity object, which values are set during runtime.</p>
  
  <p>e.g.:</p>
  
  <pre><code>Object object = new Object();
  object.property01 = "blabla";
  </code></pre>
  
  <p>Among these propertys are several references to other objects defined by a foreign_key definition.</p>
  
  <pre><code>object.object2 = object2;
  </code></pre>
  
  <p>The problem is now that the object doesn´t save the reference. When i hand the object to a viewModel the referenced object always evaluates to null.</p>
  
  <p>Any help regarding how to handle this would be highly appreciated.</p>
  
  <p>edit:
  The query i use to get a list of reference objects is as follows:</p>
  
  <pre><code>public List&lt;object2&gt; getAll(){
      var object2List = context.object2.ToList();
      return object2List;
  }
  </code></pre>
  
  <p>The function i use to create an new object is:</p>
  
  <pre><code>private void createNewObject()
  {
  _newObject = new Object();
  _newObject.prop01 = Property01;
  _object2databridge.Detach(Object2);
  _newObject.object2 = Object2;
  }
  </code></pre>