update
This commit is contained in:
@@ -41,6 +41,7 @@ public class ApplicationDbContext : DbContext, IApplicationDbContext
|
||||
}
|
||||
public DbSet<UserAddress> UserAddresss => Set<UserAddress>();
|
||||
public DbSet<Package> Packages => Set<Package>();
|
||||
public DbSet<Category> Categories => Set<Category>();
|
||||
public DbSet<Role> Roles => Set<Role>();
|
||||
public DbSet<UserRole> UserRoles => Set<UserRole>();
|
||||
public DbSet<UserWallet> UserWallets => Set<UserWallet>();
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
using CMSMicroservice.Domain.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace CMSMicroservice.Infrastructure.Persistence.Configurations;
|
||||
|
||||
public class CategoryConfiguration : IEntityTypeConfiguration<Category>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Category> builder)
|
||||
{
|
||||
builder.HasQueryFilter(p => !p.IsDeleted);
|
||||
builder.Ignore(entity => entity.DomainEvents);
|
||||
builder.HasKey(entity => entity.Id);
|
||||
builder.Property(entity => entity.Id).UseIdentityColumn();
|
||||
|
||||
builder.Property(entity => entity.Name).IsRequired(true);
|
||||
builder.Property(entity => entity.Title).IsRequired(true);
|
||||
builder.Property(entity => entity.Description).IsRequired(false);
|
||||
builder.Property(entity => entity.ImagePath).IsRequired(false);
|
||||
builder.Property(entity => entity.IsActive).IsRequired(true);
|
||||
builder.Property(entity => entity.SortOrder).IsRequired(true);
|
||||
|
||||
builder
|
||||
.HasOne(entity => entity.Parent)
|
||||
.WithMany(entity => entity.Categories)
|
||||
.HasForeignKey(entity => entity.ParentId)
|
||||
.IsRequired(false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user