title: code first migration add one to many relationship
body: <p>I currently have a "server" entity, defined as such : </p>
  
  <pre><code>public class EntityServer
  {
      public int Id { get; set; }
      public string Name { get; set; }
  }
  </code></pre>
  
  <p>I wanted to add a new "Host" entity, defined as such : </p>
  
  <pre><code>public class EntityHost
  {
      public int Id { get; set; }
      public string Name { get; set; }
      public string PublicIP { get; set; }
  
      private ICollection&lt;EntityServer&gt; _servers;
      public virtual ICollection&lt;EntityServer&gt; Servers
      {
          get { return _servers ?? (_servers = new HashSet&lt;EntityServer&gt;()); }
          set { _servers = value; }
      }
  }
  </code></pre>
  
  <p>So i added </p>
  
  <pre><code>public virtual EntityHost Host { get; set; }
  </code></pre>
  
  <p>to my server entity to link those entities with a one to many relationship</p>
  
  <pre><code>modelBuilder.Entity&lt;EntityHost&gt;()
    .HasMany&lt;EntityServer&gt;(x =&gt; x.Servers)
    .WithRequired(x =&gt; x.Host);
  </code></pre>
  
  <p>And generated a migration acordingly :</p>
  
  <pre><code>public partial class MultiHosts : DbMigration
  {
      public override void Up()
      {
          CreateTable(
              "dbo.EntityHosts",
              c =&gt; new
                  {
                      Id = c.Int(nullable: false, identity: true),
                      Name = c.String(),
                      PublicIP = c.String(),
                  })
              .PrimaryKey(t =&gt; t.Id);
  
          AddColumn("dbo.EntityServers", "Host_Id", c =&gt; c.Int(nullable: false));
          CreateIndex("dbo.EntityServers", "Host_Id");
          AddForeignKey("dbo.EntityServers", "Host_Id", "dbo.EntityHosts", "Id", cascadeDelete: true);
      }
  
      public override void Down()
      {
          DropForeignKey("dbo.EntityServers", "Host_Id", "dbo.EntityHosts");
          DropIndex("dbo.EntityServers", new[] { "Host_Id" });
          DropColumn("dbo.EntityServers", "Host_Id");
          DropTable("dbo.EntityHosts");
      }
  }
  </code></pre>
  
  <p>I've got some troubble setting a code first migration to add all it together as it outpout me a foreign key violation error when i try to access the context (which i understand as the server entity isn't linked to a host, as required by the model, because the hosts table is empty and I can't access the hosts entities to add one because of the FK violation ....)</p>
  
  <p>So, my question is : how should I insert a default host entites for the existings server ?   </p>