Skip to content

CharlieDigital/dotnet-npgsql-ef-citus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Citus Workbench

A workbench for Citus.

This repository includes:

  • Test fixtures for starting Citus using Testcontainers
  • Integration tests working with Citus using raw SQL statements
  • Integration tests working with Citus using EF and proper modeling to support migrations + distribution

Run The Tests

cd tests

# EF based tests
dotnet test --filter CitusEfTests

# Direct SQL tests
dotnet test --filter CitusDirectSqlTests

# EF based test with migrations
dotnet test --filter CitusDealershipTests

Key Concepts

  • Distribution Key. This is the shard key that is used to determine which shard that a record will be located in. In this example, we build an app for schools and thus we want to use the district_id. This field must:
    • Be included with every record that should be co-located
    • Included on the primary key of the record
    • Included on indexes
    • Included in FK references

Notes

# To force remove a migration (not connected to DB)
dotnet ef migrations remove --force

TODO

  • Auto generate idempotent distribution statements using source generators
  • Auto generate reference table statements using source generators
  • Implicitly generated reference tables for M2M
  • Inclusion of the distribution key into all queries (problematic for Prisma without it since the majority of queries are schema-based(easier for EF because of global query filters?))
    • Global query filters need to be tested for navigation properties

Resources

About

A repository demonstrating working EF + Npgsql + Citus

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages