Skip to content

Instantly share code, notes, and snippets.

@Guifgr
Last active July 6, 2023 13:29
Show Gist options
  • Save Guifgr/95d153fbf7b307bf1e7f9ca00d3ecb50 to your computer and use it in GitHub Desktop.
Save Guifgr/95d153fbf7b307bf1e7f9ca00d3ecb50 to your computer and use it in GitHub Desktop.
Auto guid to class
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<CLASSNAME>(entity =>
{
entity.Property(e => e.Guid).HasDefaultValueSql("uuid()");
entity.HasIndex(e => e.Guid).IsUnique();
});
base.OnModelCreating(modelBuilder);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment