initial commit
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using Extrudex.Domain.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace Extrudex.Infrastructure.Data.Configurations;
|
||||
|
||||
public class MaterialBaseConfiguration : BaseEntityConfiguration<MaterialBase>
|
||||
{
|
||||
public override void Configure(EntityTypeBuilder<MaterialBase> builder)
|
||||
{
|
||||
base.Configure(builder);
|
||||
|
||||
builder.Property(e => e.Name)
|
||||
.HasColumnName("name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100);
|
||||
|
||||
builder.Property(e => e.DensityGperCm3)
|
||||
.HasColumnName("density_g_per_cm3")
|
||||
.HasPrecision(10, 4)
|
||||
.IsRequired();
|
||||
|
||||
// Unique index on material base name
|
||||
builder.HasIndex(e => e.Name)
|
||||
.IsUnique()
|
||||
.HasDatabaseName("ix_material_bases_name");
|
||||
|
||||
// Relationships
|
||||
builder.HasMany(e => e.Finishes)
|
||||
.WithOne(e => e.MaterialBase)
|
||||
.HasForeignKey(e => e.MaterialBaseId)
|
||||
.HasConstraintName("fk_material_finishes_material_base");
|
||||
|
||||
builder.HasMany(e => e.Modifiers)
|
||||
.WithOne(e => e.MaterialBase)
|
||||
.HasForeignKey(e => e.MaterialBaseId)
|
||||
.HasConstraintName("fk_material_modifiers_material_base");
|
||||
|
||||
builder.HasMany(e => e.Spools)
|
||||
.WithOne(e => e.MaterialBase)
|
||||
.HasForeignKey(e => e.MaterialBaseId)
|
||||
.HasConstraintName("fk_spools_material_base");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user