title: EF7 Code First - Property cannot exist on entity type 'object' when generating migration
body: <h1>Problem</h1>
  
  <p>When trying to create a initial migration of my EF7 Code First database by executing from the command line:</p>
  
  <pre><code>dnx ef migrations add Initial
  </code></pre>
  
  <p>I get the error:</p>
  
  <p>System.InvalidOperationException: The property 'ExerciseTemplateId' cannot exist on entity type 'object' because the property is not marked as shadow state and no corresponding CLR property exists on the underlying type.
  <a href="https://gist.github.com/tdshipley/5c9269f20a5b72b71247" rel="nofollow" title="Full Stacktrace">Full Stacktrace</a></p>
  
  <p>Any ideas?</p>
  
  <h2>The Model Causing the Error</h2>
  
  <p>For some reason EF7 doesn't seem to like the primary key property <em>ExerciseTemplateId</em> on my Model:</p>
  
  <pre><code>public class ExerciseTemplate
  {
      public int ExerciseTemplateId { get; set; }
      public string InitalCode { get; set; }
      public string ClassName { get; set; }
      public string MainMethodName { get; set; }
  
      public int ExerciseForeignKey { get; set; }
      public Exercise Exercise { get; set; }
  }
  </code></pre>
  
  <h2>More Detail</h2>
  
  <p>The only interesting part of the ExerciseTemplate model is a <em>one to one</em> relationship with the Exercise model:</p>
  
  <pre><code>public class Exercise
  {
      public int ExerciseId { get; set; }
      public string Name { get; set; }
      public string Guidance { get; set; }
      public ExerciseTemplate Template { get; set; }
      public List&lt;ExerciseCategory&gt; Categories { get; set; }
      public List&lt;Test&gt; Tests { get; set; }
  }
  </code></pre>
  
  <p>This question is already long so my DBContext is in this <a href="https://gist.github.com/tdshipley/2a838456a31cb6361893" rel="nofollow" title="DB Conext Gist">DBContext Gist</a></p>
  
  <h1>Update</h1>
  
  <p>All the Models and the DB Context can be found at this <a href="https://gist.github.com/tdshipley/27745979b990f0b890f3" rel="nofollow" title="Models and Context Gist">Models and Context Gist</a></p>