diff options
| author | ivar <i@oiee.no> | 2025-10-20 00:26:34 +0200 |
|---|---|---|
| committer | ivar <i@oiee.no> | 2025-10-20 00:26:34 +0200 |
| commit | a1f0518d0cd123a791adde64f4f11bd8e44276c7 (patch) | |
| tree | 675a7dff8262eea877ec800ff1efe9b92f5d7e7d /api/WhatApi/Database.cs | |
| download | what-a1f0518d0cd123a791adde64f4f11bd8e44276c7.tar.xz what-a1f0518d0cd123a791adde64f4f11bd8e44276c7.zip | |
Initial commit
Diffstat (limited to 'api/WhatApi/Database.cs')
| -rw-r--r-- | api/WhatApi/Database.cs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/api/WhatApi/Database.cs b/api/WhatApi/Database.cs new file mode 100644 index 0000000..39de79a --- /dev/null +++ b/api/WhatApi/Database.cs @@ -0,0 +1,19 @@ +using Microsoft.EntityFrameworkCore; + +namespace WhatApi; + +public class Database(DbContextOptions<Database> options) : DbContext(options) +{ + public DbSet<Tables.Content> Content { get; set; } + public DbSet<Tables.Place> Places { get; set; } + protected override void OnModelCreating(ModelBuilder b) { + b.HasPostgresExtension("postgis"); + b.Entity<Tables.Place>(e => { + e.Property(x => x.Location).HasColumnType($"geometry(point,{Constants.Wgs84SpatialReferenceId})"); + e.HasIndex(x => x.Location).HasMethod("gist"); + e.ToTable("Place"); + }); + b.Entity<Tables.Content>(); + base.OnModelCreating(b); + } +}
\ No newline at end of file |
