Added beneficiary entity
This commit is contained in:
@@ -0,0 +1,38 @@
|
|||||||
|
namespace PostFundManagement.Domain.Configuration;
|
||||||
|
|
||||||
|
public sealed class Beneficiary : IEntityTypeConfiguration<Entities.Beneficiary>
|
||||||
|
{
|
||||||
|
public void Configure(EntityTypeBuilder<Entities.Beneficiary> builder)
|
||||||
|
{
|
||||||
|
builder.ToTable(nameof(Entities.Beneficiary).Pluralize());
|
||||||
|
|
||||||
|
builder.HasKey(pk => pk.Id);
|
||||||
|
builder.Property(f => f.ProjectId).IsRequired();
|
||||||
|
builder.Property(f => f.CreatedBy).IsRequired();
|
||||||
|
builder.Property(f => f.UserId).IsRequired();
|
||||||
|
builder.Property(f => f.CreatedAt).IsRequired().HasDefaultValueSql("now()");
|
||||||
|
builder.Property(f => f.Name).IsRequired().HasMaxLength(256);
|
||||||
|
builder.Property(f => f.Category).IsRequired().HasMaxLength(50);
|
||||||
|
builder.Property(f => f.TargetCount).IsRequired();
|
||||||
|
builder.Property(f => f.ReachedCount).IsRequired();
|
||||||
|
builder.Property(f => f.Location).IsRequired();
|
||||||
|
|
||||||
|
builder.HasOne(f => f.Project)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(fk => fk.ProjectId)
|
||||||
|
.IsRequired()
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
|
builder.HasOne(f => f.Creator)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(fk => fk.CreatedBy)
|
||||||
|
.IsRequired()
|
||||||
|
.OnDelete(DeleteBehavior.NoAction);
|
||||||
|
|
||||||
|
builder.HasOne(f => f.User)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(fk => fk.UserId)
|
||||||
|
.IsRequired()
|
||||||
|
.OnDelete(DeleteBehavior.NoAction);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
namespace PostFundManagement.Domain.Entities;
|
||||||
|
|
||||||
|
[EntityTypeConfiguration<Configuration.Beneficiary, Beneficiary>]
|
||||||
|
public class Beneficiary : Models.Beneficiary
|
||||||
|
{
|
||||||
|
public virtual Project? Project { get; set; }
|
||||||
|
|
||||||
|
public virtual User? Creator { get; set; }
|
||||||
|
|
||||||
|
public virtual User? User { get; set; }
|
||||||
|
}
|
||||||
@@ -4,6 +4,8 @@ namespace PostFundManagement.Infrastructure.Database;
|
|||||||
|
|
||||||
public sealed class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : DbContext(options)
|
public sealed class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : DbContext(options)
|
||||||
{
|
{
|
||||||
|
public DbSet<Beneficiary> Beneficiaries => Set<Beneficiary>();
|
||||||
|
|
||||||
public DbSet<Evidence> Evidences => Set<Evidence>();
|
public DbSet<Evidence> Evidences => Set<Evidence>();
|
||||||
|
|
||||||
public DbSet<Risk> Risks => Set<Risk>();
|
public DbSet<Risk> Risks => Set<Risk>();
|
||||||
|
|||||||
Reference in New Issue
Block a user