using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace GeoRitmMover.Mover.Data.EntityConfigurations;
public class AreaMapEntityConfiguration : IEntityTypeConfiguration<AreaMap>
{
	public void Configure(EntityTypeBuilder<AreaMap> builder)
	{
		_ = builder.HasKey(x => x.Id);

		_ = builder.Property(x => x.From)
			.IsRequired();
		_ = builder.HasIndex(x => x.From).IsUnique();

		_ = builder.Property(x => x.To)
			.IsRequired()
			.HasConversion(x => x.Value, x => new(x));
		_ = builder.HasIndex(x => x.To).IsUnique();
	}
}
