title: Code First entity framework and foreign keys
body: <p>Imagine I have a database created by code first that looks like this.</p>
  
  <pre><code>Movie (table)
  ID int PK
  MoveiName nvarchar(100)
  
  Actor (table)
  ID int PK
  ActorName nvarchar(100)
  Movie_ID int FK
  </code></pre>
  
  <p>These are the models I would have used, obviously not exactly like this but you'll get my point.</p>
  
  <pre><code>class Movie
  {  
      int ID{get;set;}
      string MovieName {get;set;}
      List&lt;Actor&gt; Actors {get;set}
  }
  
  class Actor
  {
      int ID{get;set}
      string Actorname{get;set}
      Movie Movie{get;set;}
      int Move_ID{get;set;}
  }
  </code></pre>
  
  <p>Database first enables me to query the movie from an actor but also lets me set the forgien key property of the actor to update the database. I cant do this in code first because the foreign key isnt in the model only the object. I prefer not to get the Movie object and set the property, if i know the id of my movie I'd rather just set the foreign key without the call to get the movie.</p>
  
  <p>Make sense? lol</p>
  
  <p>I want to use codefirst and entity migrations but i want the same ability as database first to set a foreign key on an object.</p>
  
  <p>Cheers for the help :-D</p>