lucabriguglia/OpenCQRS

[Question] Is it possible to customize partition key on cosmos store?

xaviersolau opened this issue · 1 comments

I would like to use other properties as partition key for cosmos store but it looks like it is hard coded in CosmosDomainDbContext :

builder.Entity<AggregateEntity>()
                .ToContainer(_settings.AggregateContainerName)
                .HasPartitionKey(p => p.Type)
                .HasNoDiscriminator();

builder.Entity<CommandEntity>()
                .ToContainer(_settings.CommandContainerName)
                .HasPartitionKey(p => p.Type)
                .HasNoDiscriminator();

builder.Entity<EventEntity>()
                .ToContainer(_settings.EventContainerName)
                .HasPartitionKey(p => p.Type)
                .HasNoDiscriminator();

Any idea ?
By the way why did you chose the Type as partition key? Why not the AggregateId for example?

You are right, the AggregateId would have been the right choice. Unfortunately it's not possible at the moment but in the mean time you can create a custom provider to address that.