title: The seed entity for entity type 'CustomDataType' cannot be added because no value was provided for the required property 'SoftwareVersionVersion'
body: <p>I'm fairly new to EF Core but I am trying to seed a database using EF Core 6 and I am getting the following error when trying to create a migration.</p>
  <blockquote>
  <p>The seed entity for entity type 'CustomDataType' cannot be added
  because no value was provided for the required property
  'SoftwareVersionVersion'.</p>
  </blockquote>
  <p>I have a BaseEntity class which most other entity classes inherit from that looks like this:</p>
  <pre><code>public class BaseEntity
  {
      [Key]
      public int Id { get; set; }
      public SoftwareVersion SoftwareVersion { get; set; }
  }
  </code></pre>
  <p>I think the issue may have something to do with the fact that my SoftwareVersion class contains a single column of type string which acts as the primary key:</p>
  <pre><code>public class SoftwareVersion
  {
      [Key]
      [DatabaseGenerated(DatabaseGeneratedOption.None)]
      public string Version { get; set; }
  
      public SoftwareVersion() 
      {
          this.Version = &quot;1.0.0&quot;;
      }
  }
  </code></pre>
  <p>Here is my CustomDataType class:</p>
  <pre><code>public class CustomDataType : BaseEntity
  {
      public int Code { get; set; }
      public string Description { get; set; }
  }
  </code></pre>
  <p>I have been following the documentation to seed my database using the modelBuilder in the OnModelCreating method of my context:</p>
  <pre><code>protected override void OnModelCreating(ModelBuilder modelBuilder)
  {
      modelBuilder.Seed();
  }
  
  public static void Seed(this ModelBuilder modelBuilder)
  {
      modelBuilder.Entity&lt;SoftwareVersion&gt;().HasData(SoftwareVersionSeedData());
      modelBuilder.Entity&lt;CustomDataType&gt;().HasData(CustomDataTypeSeedData());
  }
  
  public SoftwareVersion[] SoftwareVersionSeedData()
  {
      return new[]
      {
           new SoftwareVersion { Version = &quot;1.0.0&quot; }
      };
  }
  
  public static CustomDataType[] CustomDataTypeSeedData()
  {
      return new[]
      {
          new CustomDataType { Id = 1, Code = 1000001, Description = &quot;Binary&quot; },
          new CustomDataType { Id = 2, Code = 1000002, Description = &quot;Datetime&quot; },
          new CustomDataType { Id = 3, Code = 1000003, Description = &quot;Integer&quot; },
          new CustomDataType { Id = 4, Code = 1000004, Description = &quot;Other&quot; },
          new CustomDataType { Id = 5, Code = 1000005, Description = &quot;String&quot; },
          new CustomDataType { Id = 6, Code = 1000006, Description = &quot;Boolean&quot; },
      };
  }
  </code></pre>
  <p>Running a migration with my seed data in the current state obviously causes an error because I am not defining a SoftwareVersion in the CustomDataTypeSeedData method but even when I use the following pattern I am still getting the same error:</p>
  <pre><code>new CustomDataType { Id = 1, Code = 1000001, Description = &quot;Binary&quot;, SoftwareVersion = new SoftwareVersion() },
  </code></pre>
  <p>I'm just not sure where exactly I'm going wrong or, indeed, if there is a better way to fix this.  The only way I've found to get around the error when creating a migration is to make my SoftwareVersion nullable in my BaseEntity but this is not ideal as the SoftwareVersion is a required field.</p>