Closed aldycool closed 3 years ago
Hi @aldycool,
This is my Entity
Essentially, has a combination of both a Guid Id and a Tenant Id.
Hi @iammukeshm,
My mistake, I thought the entities are on the Shared
project.
I see, the BaseEntity
super class carries the Id
field and it became the primary key by convention in EF Core. The tenancy identifier is the TenantId
field in the derived class. Also, in order to be compliant with Citus sharding, we can enforce the creation of composite primary key (to override the convention Id
as primary key) by using the EF Core's ModelBuilder.HasKey()
during OnModelCreating()
, as specified in the example: https://docs.microsoft.com/en-us/ef/core/modeling/keys?tabs=data-annotations#configuring-a-primary-key.
Very nice, your boilerplate is very flexible to allow this. Thanks for your insights!
Hi,
Have you considered about database sharding plan? If you've planned to support it, I've read that you primarily support PostgreSQL, and Citus Data is one of the sharding solution for it.
According to Citus docs, one of the requirements is to have composite primary keys:
http://docs.citusdata.com/en/v10.1/use_cases/multi_tenant.html#preparing-tables-and-ingesting-data
But it seems that your Dtos are based on a single primary key:
https://github.com/fullstackhero/dotnet-webapi-boilerplate/blob/main/src/Shared/Shared.DTOs/Catalog/ProductDetailsDto.cs
What do you think about this? Thanks