Skip to content

Cosmos DB Expansion #160

@richard-einfinity

Description

@richard-einfinity

Picking up from a discussion we were having over on the Mobile Apps repository. The OOB EntityTableRepository will work with the basic cosmos DB configuration but falls down a little bit when you start introducing things like partition keys. The default behaviour of EntityFrameworkCore with cosmosdb is that it creates a partition key of __partitionKey if you don't specify one. This limits the amount of Data Stored to 20GB.

When the partition key is specified we need a mechanism for passing it to the repository to the Find and Single LINQ methods in the repository.

We previously discussed mechanisms like packing the keys and passing additional parameters through the query string or headers. The current AccessControlProvider will now work will with filtering the partitioned data, with the release of EF9 the GetDataView expression should be lifted up so that parameters that are partition keys are recognised as such. So no work needs to be done there.

The find method in the OOB EntityTableRepository will fail as it requires that the id and the partition keys are passed through, with the partition key values ordered in the same order as the partition keys are defined on the model.

I think there are 2 potential ways of supporting partition keys.

We could expand the AccessControlProvider to include methods to return the keys to pass to the Repository and perhaps and expression for the lookups. My concern with this approach is polluting the ecosystem with requirements of the cosmosdb implementation. The only question being is if there is composite primary key lookups requirement with the other providers which this will also support.

Or we could look at a Cosmos specific repository which passes an Options object akin to the cosmosdb work in progress on the 8.0 branch of the mobile apps project. My concern with this approach is are we shifting some of the responsibility to the repository which really belongs further up the chain, especially if we're dealing with query strings or headers.

Happy to take a look at this if we can get some consensus on the path forward.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ServerImprovements or additions to the server code

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions