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