Matt-Crow / GearBox

A C# MMORPG-like game.
0 stars 0 forks source link

Add database #105

Closed Matt-Crow closed 1 day ago

Matt-Crow commented 4 months ago
Matt-Crow commented 1 week ago

Multiple DB contexts are causing pain for migrations, might need to do more research or simply write the database creation scripts myself (more likely).

Matt-Crow commented 1 week ago

EFCore is having issues finding migrations outside of the public schema. This is because it executes this query when I run dotnet ef migrations list -c ...

SELECT EXISTS (
          SELECT 1 FROM pg_catalog.pg_class c
          JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace
          WHERE n.nspname='public' AND
                c.relname='__EFMigrationsHistory'
      )

It does this even when I specify the connection string... but why? This might have something to do with it: https://github.com/npgsql/efcore.pg/issues/2775

Matt-Crow commented 1 week ago

Post this somewhere:

I have multiple database contexts, and have one schema for each. dotnet ef migrations list doesn't recognize which migrations have been applied, as it always searches the public schema. However, dotnet ef database update creates the migration history table in the schema denoted by the connection string.

Matt-Crow commented 3 days ago

Running into issues when saving to the database after loading, maybe EFCore thinks I want to update existing items (I don't). Also need to set item quantity and ID when loading from the DB.

Need refactor!

Matt-Crow commented 1 day ago

Done, though I'll have a separate item for refactoring