Skip to content

Commit

Permalink
Added NetworkConfig EF Entity Type Configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
RobThree committed Jul 6, 2021
1 parent 94fa65c commit b8097a0
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Network.cs
@@ -1,4 +1,6 @@
using System.ComponentModel.DataAnnotations;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Net;

Expand Down Expand Up @@ -65,4 +67,15 @@ private static byte[] CreateMask(byte[] prefixBytes, int prefixLength)
}
}

internal class NetworkConfig : IEntityTypeConfiguration<Network>
{
public void Configure(EntityTypeBuilder<Network> entity)
{
entity.Property("_prefixbytes")
.HasColumnName(nameof(Network.Prefix));
entity.Property("_last")
.HasColumnName("Last");
entity.HasIndex(new[] { "_prefixbytes", "_last" }).IsUnique();
}
}
}

0 comments on commit b8097a0

Please sign in to comment.