title: Entity Framework Core Auto Generated guid
body: <p>Can some One guide me I want <strong><code>primeryKey</code></strong> of a table as <strong><code>guid</code></strong> having db generated value on insert.</p>
  <pre><code>[Key]
  [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  public Guid Id { get; set; }
  </code></pre>
  <p>but it's giving <code>error</code></p>
  <blockquote>
  <p>The seed entity for entity type 'User' cannot be added because there was no value provided for the required property 'Id'.</p>
  </blockquote>
  <p>Here is my actual model classes and DbContxt class:</p>
  <pre><code>public class BaseModel
  {
       [Key]
       [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
       public Guid Id { get; set; }
  
       [Required]
       [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
       public DateTime CreatedOn { get; set; } = DateTime.UtcNow;
  
  
       [DatabaseGenerated(DatabaseGeneratedOption.Computed)]
       public DateTime? UpdatedOn { get; set; }
  
       [DatabaseGenerated(DatabaseGeneratedOption.Computed)]
       public DateTime LastAccessed { get; set; }
   }
  
   public class User : BaseModel
   {
          [Required]
          [MinLength(3)]
          public string Name { get; set; }
  
          [Required]
          [MinLength(3)]
          [EmailAddress]
          public string Email { get; set; }
  
          [Required]
          [MinLength(6)]
          public string Password { get; set; }
    }
  </code></pre>
  <p>Then in the MyDbContext:</p>
  <pre><code>public class MyDbContext: DbContext
      {
          public MyDbContext(DbContextOptions&lt;MyDbContext&gt; options)
              : base(options)
          {
          }
  
          protected override void OnModelCreating(ModelBuilder mb)
          {
              base.OnModelCreating(mb);
              
              mb.Entity&lt;User&gt;().HasData(
                  new User() { Email = &quot;Mubeen@gmail.com&quot;, Name = &quot;Mubeen&quot;, Password = &quot;123123&quot; },
                  new User() { Email = &quot;Tahir@gmail.com&quot;, Name = &quot;Tahir&quot;, Password = &quot;321321&quot; },
                  new User() { Email = &quot;Cheema@gmail.com&quot;, Name = &quot;Cheema&quot;, Password = &quot;123321&quot; }
                  );
          }
  
          public DbSet&lt;User&gt; User { get; set; }
      }
  </code></pre>
  <p><strong>Any help please!</strong></p>