title: Entityframework core code first migration of Complex type
body: <p>I am creating a basic application using ef core. In it I have a Person and Address class. Address is a complex type. When I try to run migration command (add-migration initialmigration) by using Package Manager concole. It throws an exception. It says that I must define Id for this complex type. Below is the following code.</p>
  <pre><code>public class Person
  {
      public int Id { get; set; }
      public string Name { get; set; }
      public int Age { get; set; }
  
      public ICollection&lt;Address&gt; Addresses { get; set; }
  }
  
  public class Address 
  {
      public String Street { get; private set; }
     
  
      private Address()
      {
      }
  
      public Address(string street)
      {
          Street = street;
        
      }       
  }
  
  public class MyContext : DbContext
  {
      public MyContext() { 
         
         
      }
  
      DbSet&lt;Person&gt; Persons { get; set; }
  
      protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
      {
          if (!optionsBuilder.IsConfigured)
          {
              optionsBuilder.UseSqlServer(&quot;Server=.;Database=MyTest;Trusted_Connection=True;&quot;);
          }
      }
  
      protected override void OnModelCreating(ModelBuilder modelBuilder)
      {
          modelBuilder.Entity&lt;Person&gt;().Property(k =&gt; k.Id).ValueGeneratedOnAdd();
  
          modelBuilder.Entity&lt;Person&gt;(entity =&gt; entity.OwnsMany(m =&gt; m.Addresses, address =&gt; 
              
              address.Property(x =&gt; x.Street).HasColumnName(&quot;Street&quot;)
              
              ));
      }
  }
  </code></pre>
  <p>How could I solve this issues, so that I could migrate my complex type?</p>