From 45eb6d7b6b4d9d236132250bee497b19bfed00fc Mon Sep 17 00:00:00 2001 From: Rene Bentes Pinto Date: Thu, 6 Oct 2022 20:33:36 -0300 Subject: [PATCH] =?UTF-8?q?refactor:=20Define=20a=20chave=20prim=C3=A1ria?= =?UTF-8?q?=20da=20categoria?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Blog/Data/Mappings/CategoryMap.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Blog/Data/Mappings/CategoryMap.cs b/Blog/Data/Mappings/CategoryMap.cs index b67d8e9..922cf41 100644 --- a/Blog/Data/Mappings/CategoryMap.cs +++ b/Blog/Data/Mappings/CategoryMap.cs @@ -9,5 +9,14 @@ public class CategoryMap : IEntityTypeConfiguration public void Configure(EntityTypeBuilder 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(); } }