Skip to content

Commit

Permalink
refactor: Define a chave primária da categoria
Browse files Browse the repository at this point in the history
  • Loading branch information
renebentes committed Oct 6, 2022
1 parent 5cd0212 commit 45eb6d7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Blog/Data/Mappings/CategoryMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,14 @@ public class CategoryMap : IEntityTypeConfiguration<Category>
public void Configure(EntityTypeBuilder<Category> builder)
{
builder.ToTable(nameof(Category));

// Define a chave primária
builder.HasKey(c => c.Id);

// Define que será usado IDENTITY(1, 1) para geração
// automática da chave
builder.Property(c => c.Id)
.ValueGeneratedOnAdd()
.UseIdentityColumn();
}
}

0 comments on commit 45eb6d7

Please sign in to comment.