mirror of
https://github.com/farcasclaudiu/PracticeCalendar.git
synced 2026-06-22 07:01:16 +03:00
31 lines
1.0 KiB
C#
31 lines
1.0 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
using PracticeCalendar.Domain.Entities.Product;
|
|
using PracticeCalendar.Domain.ValueObjects;
|
|
|
|
namespace PracticeCalendar.Infrastructure.Persistence.Configuration
|
|
{
|
|
public class ProductConfiguration : IEntityTypeConfiguration<Product>
|
|
{
|
|
public void Configure(EntityTypeBuilder<Product> builder)
|
|
{
|
|
builder.Property(x => x.Name)
|
|
.HasMaxLength(100)
|
|
.IsRequired();
|
|
builder.Property(x => x.Category)
|
|
.HasMaxLength(100)
|
|
.IsRequired();
|
|
builder.OwnsOne(product => product.UnitPrice, price =>
|
|
{
|
|
price.Property(p => p.Currency)
|
|
.HasColumnName(nameof(Price.Currency))
|
|
.HasMaxLength(5)
|
|
.IsRequired();
|
|
price.Property(p => p.Value)
|
|
.HasColumnName(nameof(Price.Value))
|
|
.IsRequired();
|
|
});
|
|
}
|
|
}
|
|
}
|