| | | 1 | | using AsiBackbone.EntityFrameworkCore.Persistence; |
| | | 2 | | using Microsoft.EntityFrameworkCore; |
| | | 3 | | using Microsoft.EntityFrameworkCore.Metadata.Builders; |
| | | 4 | | |
| | | 5 | | namespace AsiBackbone.EntityFrameworkCore.Configurations; |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// Configures the Entity Framework Core persistence mapping for <see cref="AsiBackboneHandshakeAcknowledgmentEntity" /> |
| | | 9 | | /// </summary> |
| | | 10 | | public sealed class AsiBackboneHandshakeAcknowledgmentEntityConfiguration |
| | | 11 | | : IEntityTypeConfiguration<AsiBackboneHandshakeAcknowledgmentEntity> |
| | | 12 | | { |
| | | 13 | | private const int IdentifierMaxLength = 128; |
| | | 14 | | private const int SchemaVersionMaxLength = 64; |
| | | 15 | | private const int DisplayNameMaxLength = 256; |
| | | 16 | | private const int ActorTypeMaxLength = 64; |
| | | 17 | | private const int AcknowledgmentCodeMaxLength = 128; |
| | | 18 | | private const int CorrelationMaxLength = 128; |
| | | 19 | | private const int ConcurrencyStampMaxLength = 64; |
| | | 20 | | |
| | | 21 | | /// <inheritdoc /> |
| | | 22 | | public void Configure(EntityTypeBuilder<AsiBackboneHandshakeAcknowledgmentEntity> builder) |
| | | 23 | | { |
| | 22 | 24 | | ArgumentNullException.ThrowIfNull(builder); |
| | | 25 | | |
| | 22 | 26 | | _ = builder.ToTable("AsiBackboneHandshakeAcknowledgments"); |
| | | 27 | | |
| | 22 | 28 | | _ = builder.HasKey(acknowledgment => acknowledgment.Id); |
| | | 29 | | |
| | 22 | 30 | | _ = builder.Property(acknowledgment => acknowledgment.Id) |
| | 22 | 31 | | .ValueGeneratedNever(); |
| | | 32 | | |
| | 22 | 33 | | _ = builder.Property(acknowledgment => acknowledgment.ConcurrencyStamp) |
| | 22 | 34 | | .IsRequired() |
| | 22 | 35 | | .HasMaxLength(ConcurrencyStampMaxLength) |
| | 22 | 36 | | .IsConcurrencyToken(); |
| | | 37 | | |
| | 22 | 38 | | _ = builder.Property(acknowledgment => acknowledgment.AcknowledgmentId) |
| | 22 | 39 | | .IsRequired() |
| | 22 | 40 | | .HasMaxLength(IdentifierMaxLength); |
| | | 41 | | |
| | 22 | 42 | | _ = builder.Property(acknowledgment => acknowledgment.SchemaVersion) |
| | 22 | 43 | | .IsRequired() |
| | 22 | 44 | | .HasMaxLength(SchemaVersionMaxLength); |
| | | 45 | | |
| | 22 | 46 | | _ = builder.Property(acknowledgment => acknowledgment.HandshakeId) |
| | 22 | 47 | | .IsRequired() |
| | 22 | 48 | | .HasMaxLength(IdentifierMaxLength); |
| | | 49 | | |
| | 22 | 50 | | _ = builder.Property(acknowledgment => acknowledgment.ActorId) |
| | 22 | 51 | | .IsRequired() |
| | 22 | 52 | | .HasMaxLength(IdentifierMaxLength); |
| | | 53 | | |
| | 22 | 54 | | _ = builder.Property(acknowledgment => acknowledgment.ActorType) |
| | 22 | 55 | | .HasConversion<string>() |
| | 22 | 56 | | .IsRequired() |
| | 22 | 57 | | .HasMaxLength(ActorTypeMaxLength); |
| | | 58 | | |
| | 22 | 59 | | _ = builder.Property(acknowledgment => acknowledgment.ActorDisplayName) |
| | 22 | 60 | | .HasMaxLength(DisplayNameMaxLength); |
| | | 61 | | |
| | 22 | 62 | | _ = builder.Property(acknowledgment => acknowledgment.AcknowledgmentCode) |
| | 22 | 63 | | .IsRequired() |
| | 22 | 64 | | .HasMaxLength(AcknowledgmentCodeMaxLength); |
| | | 65 | | |
| | 22 | 66 | | _ = builder.Property(acknowledgment => acknowledgment.Acknowledged) |
| | 22 | 67 | | .IsRequired(); |
| | | 68 | | |
| | 22 | 69 | | _ = builder.Property(acknowledgment => acknowledgment.OccurredUtc) |
| | 22 | 70 | | .IsRequired(); |
| | | 71 | | |
| | 22 | 72 | | _ = builder.Property(acknowledgment => acknowledgment.CorrelationId) |
| | 22 | 73 | | .HasMaxLength(CorrelationMaxLength); |
| | | 74 | | |
| | 22 | 75 | | _ = builder.Property(acknowledgment => acknowledgment.TraceId) |
| | 22 | 76 | | .HasMaxLength(CorrelationMaxLength); |
| | | 77 | | |
| | 22 | 78 | | _ = builder.HasIndex(acknowledgment => acknowledgment.AcknowledgmentId) |
| | 22 | 79 | | .IsUnique(); |
| | | 80 | | |
| | 22 | 81 | | _ = builder.HasIndex(acknowledgment => acknowledgment.SchemaVersion); |
| | | 82 | | |
| | 22 | 83 | | _ = builder.HasIndex(acknowledgment => acknowledgment.HandshakeId); |
| | | 84 | | |
| | 22 | 85 | | _ = builder.HasIndex(acknowledgment => acknowledgment.ActorId); |
| | | 86 | | |
| | 22 | 87 | | _ = builder.HasIndex(acknowledgment => acknowledgment.ActorType); |
| | | 88 | | |
| | 22 | 89 | | _ = builder.HasIndex(acknowledgment => acknowledgment.AcknowledgmentCode); |
| | | 90 | | |
| | 22 | 91 | | _ = builder.HasIndex(acknowledgment => acknowledgment.Acknowledged); |
| | | 92 | | |
| | 22 | 93 | | _ = builder.HasIndex(acknowledgment => acknowledgment.OccurredUtc); |
| | | 94 | | |
| | 22 | 95 | | _ = builder.HasIndex(acknowledgment => acknowledgment.CorrelationId); |
| | | 96 | | |
| | 22 | 97 | | _ = builder.HasIndex(acknowledgment => acknowledgment.TraceId); |
| | | 98 | | |
| | 22 | 99 | | _ = builder.HasIndex(acknowledgment => new |
| | 22 | 100 | | { |
| | 22 | 101 | | acknowledgment.HandshakeId, |
| | 22 | 102 | | acknowledgment.OccurredUtc |
| | 22 | 103 | | }); |
| | | 104 | | |
| | 22 | 105 | | _ = builder.HasIndex(acknowledgment => new |
| | 22 | 106 | | { |
| | 22 | 107 | | acknowledgment.ActorId, |
| | 22 | 108 | | acknowledgment.OccurredUtc |
| | 22 | 109 | | }); |
| | | 110 | | |
| | 22 | 111 | | _ = builder.HasIndex(acknowledgment => new |
| | 22 | 112 | | { |
| | 22 | 113 | | acknowledgment.CorrelationId, |
| | 22 | 114 | | acknowledgment.OccurredUtc |
| | 22 | 115 | | }); |
| | 22 | 116 | | } |
| | | 117 | | } |