Last active
November 26, 2020 17:27
-
-
Save rurounijones/c4adc0b90d4cf47fb3bc480af814a989 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GameContext : DbContext | |
{ | |
public DbSet<Unit> Units { get; set; } | |
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) | |
{ | |
optionsBuilder | |
.UseNpgsql("Host=192.168.1.27;Database=tac_scribe;Username=tac_scribe;Password=tac_scribe", | |
o => o.UseNetTopologySuite()) | |
.UseSnakeCaseNamingConvention(); | |
} | |
protected override void OnModelCreating(ModelBuilder modelBuilder) | |
{ | |
modelBuilder.Entity<Unit>() | |
.Property(b => b.Id).HasColumnName("id"); | |
} | |
} | |
public class Unit | |
{ | |
[Column("id")] | |
public string Id { get; set; } | |
[Column(TypeName="geography (point)")] | |
public Point Position { get; set; } | |
public double Altitude { get; set; } | |
public string Type { get; set; } | |
public string Name { get; set; } | |
public string Pilot { get; set; } | |
public string Group { get; set; } | |
public int Coalition { get; set; } | |
public int Heading { get; set; } | |
public DateTime UpdatedAt { get; set; } | |
public int Speed { get; set; } | |
public bool Deleted { get; set; } | |
public List<Unit> Units { get; } = new List<Unit>(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Table: public.units | |
-- DROP TABLE public.units; | |
CREATE TABLE public.units | |
( | |
id text COLLATE pg_catalog."default" NOT NULL, | |
"position" geography NOT NULL, | |
altitude double precision NOT NULL DEFAULT 0, | |
type text COLLATE pg_catalog."default", | |
name text COLLATE pg_catalog."default", | |
pilot text COLLATE pg_catalog."default", | |
"group" text COLLATE pg_catalog."default", | |
coalition integer NOT NULL, | |
heading integer, | |
updated_at timestamp without time zone NOT NULL, | |
deleted boolean, | |
speed integer NOT NULL, | |
CONSTRAINT units_pkey PRIMARY KEY (id) | |
) | |
WITH ( | |
OIDS = FALSE | |
) | |
TABLESPACE pg_default; | |
ALTER TABLE public.units | |
OWNER to tac_scribe; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Enabled logging. The above code along with the following select
Results in the following SQL which includes a spurious
u.unit_id
. Looks like some sort of bug with primary key namingThis is happening even if we remove all the customisation and have