-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathPollingStationConfiguration.cs
More file actions
30 lines (26 loc) · 1.36 KB
/
PollingStationConfiguration.cs
File metadata and controls
30 lines (26 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Vote.Monitor.Domain.EntitiesConfiguration;
public class PollingStationConfiguration : IEntityTypeConfiguration<PollingStation>
{
public void Configure(EntityTypeBuilder<PollingStation> builder)
{
builder.HasKey(p => p.Id);
builder.Property(p => p.Id).IsRequired();
builder.Property(p => p.Address).HasMaxLength(2024).IsRequired();
builder.Property(p => p.DisplayOrder).IsRequired();
builder.Property(p => p.Tags).IsRequired(false).HasDefaultValueSql("'{}'::JSONB");
builder.Property(p => p.Level1).HasMaxLength(256).IsRequired();
builder.Property(p => p.Level2).HasMaxLength(256).IsRequired(false);
builder.Property(p => p.Level3).HasMaxLength(256).IsRequired(false);
builder.Property(p => p.Level4).HasMaxLength(256).IsRequired(false);
builder.Property(p => p.Level5).HasMaxLength(256).IsRequired(false);
builder.Property(p => p.Number).HasMaxLength(256).IsRequired();
builder.Property(p => p.Latitude).IsRequired(false).HasDefaultValue(null);
builder.Property(p => p.Longitude).IsRequired(false).HasDefaultValue(null);
builder
.HasOne(x => x.ElectionRound)
.WithMany()
.HasForeignKey(x => x.ElectionRoundId)
.OnDelete(DeleteBehavior.Cascade);
}
}