-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Aplica mapeamento inicial do modelo de usuários
- Loading branch information
1 parent
2de4478
commit 7e25787
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using Blog.Models; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace Blog.Data.Mappings; | ||
|
||
public class UserMap : IEntityTypeConfiguration<User> | ||
{ | ||
public void Configure(EntityTypeBuilder<User> builder) | ||
{ | ||
builder.ToTable(nameof(User)); | ||
|
||
builder.HasKey(u => u.Id); | ||
|
||
builder.Property(u => u.Id) | ||
.ValueGeneratedOnAdd() | ||
.UseIdentityColumn(); | ||
|
||
builder.Property(u => u.Name) | ||
.IsRequired() | ||
.HasColumnType("NVARCHAR") | ||
.HasMaxLength(80); | ||
|
||
builder.Property(u => u.Email) | ||
.IsRequired() | ||
.HasColumnType("VARCHAR") | ||
.HasMaxLength(200); | ||
|
||
builder.Property(u => u.PasswordHash) | ||
.IsRequired() | ||
.HasColumnType("VARCHAR") | ||
.HasMaxLength(255); | ||
|
||
builder.Property(u => u.Bio) | ||
.IsRequired() | ||
.HasColumnType("TEXT"); | ||
|
||
builder.Property(u => u.Image) | ||
.IsRequired() | ||
.HasColumnType("VARCHAR") | ||
.HasMaxLength(2000); | ||
|
||
builder.Property(u => u.Slug) | ||
.IsRequired() | ||
.HasColumnType("VARCHAR") | ||
.HasMaxLength(80); | ||
|
||
builder.HasIndex(u => u.Slug, "IX_User_Slug") | ||
.IsUnique(); | ||
} | ||
} |