title: EF Code First - Seeding data that needs foreign key reference
body: <p>I have 2 entities - Roles and Administrators. Roles has two values - Search Admin and Super Admin. I have created these using EF Code First model. Now I am trying to seed values to the database and I add the roles first:</p>
  
  <pre><code>    private static void SeedRoles(PayByPhoneDbContext context)
      {
          var roles = new List&lt;Role&gt; {new Role {Name = "Search Administrator"}, new Role {Name = "Super Administrator"}};
          roles.ForEach(role =&gt; context.Roles.Add(role));
      }
  </code></pre>
  
  <p>Now I want to use one of the roles created above to be used while adding administrators:</p>
  
  <pre><code>    private void SeedAdministrators(PayByPhoneDbContext context)
      {
          var administrators = new List&lt;Administrator&gt;{new Administrator {Email = "a@a.com", Name = "Achinth Gurkhi", Password = "hello", Active = true, Role = ? }}
      }
  </code></pre>
  
  <p>How do I set Role here? Should I say <code>Role = new Role { Name = "Super Administrator" }</code> or search for Role inserted by SeedRoles method? Also, how do I search for an existing role using the context?</p>