48 lines
1.7 KiB
C#
48 lines
1.7 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
using OnProfNext.Shared.Models;
|
|
|
|
namespace OnProfNext.Server.Configurations
|
|
{
|
|
public class ProjectConfiguration : IEntityTypeConfiguration<Project>
|
|
{
|
|
public void Configure(EntityTypeBuilder<Project> entity)
|
|
{
|
|
entity.ToTable("Projects");
|
|
// Primary Key
|
|
entity.HasKey(p => p.Id);
|
|
// Project Name
|
|
entity.Property(p => p.ProjectName)
|
|
.IsRequired()
|
|
.HasMaxLength(200);
|
|
// Description
|
|
entity.Property(p => p.Description)
|
|
.HasMaxLength(1000);
|
|
// Project Manager
|
|
entity.Property(p => p.ProjectManager)
|
|
.HasMaxLength(100);
|
|
// Status
|
|
entity.Property(p => p.Status)
|
|
.IsRequired()
|
|
.HasMaxLength(50)
|
|
.HasDefaultValue("Geplant");
|
|
// Start Date
|
|
entity.Property(p => p.StartDate)
|
|
.IsRequired()
|
|
.HasDefaultValueSql("SYSDATETIME()");
|
|
// End Date
|
|
entity.Property(p => p.EndDate);
|
|
// Mandant
|
|
entity.Property(p => p.MandantId)
|
|
.HasDefaultValue(1);
|
|
// Timestamps
|
|
entity.Property(p => p.CreatedAt)
|
|
.HasDefaultValueSql("SYSDATETIME()")
|
|
.ValueGeneratedOnAdd();
|
|
entity.Property(p => p.UpdatedAt)
|
|
.HasDefaultValueSql("SYSDATETIME()")
|
|
.ValueGeneratedOnAddOrUpdate();
|
|
}
|
|
}
|
|
}
|