Infrasctructure: Update StreetDBContext with Street Entity

This commit is contained in:
Jonas Seiler 2025-04-03 11:02:22 +02:00
parent 3a40657b1d
commit 226e5e4e3e

View File

@ -2,6 +2,23 @@ using Microsoft.EntityFrameworkCore;
public class StreetDbContext : DbContext public class StreetDbContext : DbContext
{ {
public DbSet<Street> Streets { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.HasPostgresExtension("postgis");
modelBuilder.Entity<Street>(entity =>
{
entity.HasKey(s => s.Name);
entity.Property(s => s.Capacity).IsRequired();
entity.Property(s => s.Geometry).HasColumnType("geometry(LineString,4326)").IsRequired();
entity.Property(s => s.Version).IsRowVersion();
});
}
public StreetDbContext(DbContextOptions<StreetDbContext> options) : base(options) public StreetDbContext(DbContextOptions<StreetDbContext> options) : base(options)
{ {