Skip to content

CHR0011: Declarative projection event types must be from the same event store

A declarative projection subscribes to one event store’s event stream. Referencing event types from multiple event stores would require multiple subscriptions, which Chronicle does not support for a single projection. Ensure all event types referenced in the Define() method belong to the same event store, or split into separate projections—one per event store.

Error

using Cratis.Chronicle.Events;
using Cratis.Chronicle.Projections;
public record Chr0011ViolationProductInventory(string Name, int Stock);
[EventType("product-added")]
[EventStore("catalog")]
public record Chr0011ViolationProductAdded(string Name, int InitialStock);
[EventType("stock-received")]
[EventStore("warehouse")]
public record Chr0011ViolationStockReceived(int Quantity);
// Error CHR0011: Declarative projection references event types from multiple event stores:
// "catalog", "warehouse". All event types in a projection must originate from the same event store.
public class Chr0011ViolationProductInventoryProjection : IProjectionFor<Chr0011ViolationProductInventory>
{
public void Define(IProjectionBuilderFor<Chr0011ViolationProductInventory> builder)
{
builder
.From<Chr0011ViolationProductAdded>()
.From<Chr0011ViolationStockReceived>();
}
}
using Cratis.Chronicle.Events;
using Cratis.Chronicle.Projections;
public record Chr0011FixProductInventory(string Name, int Stock);
[EventType("product-added")]
[EventStore("catalog")]
public record Chr0011FixProductAdded(string Name, int InitialStock);
[EventType("product-restocked")]
[EventStore("catalog")]
public record Chr0011FixProductRestocked(int Quantity);
// All event types belong to the same event store: "catalog".
public class Chr0011FixProductInventoryProjection : IProjectionFor<Chr0011FixProductInventory>
{
public void Define(IProjectionBuilderFor<Chr0011FixProductInventory> builder)
{
builder
.From<Chr0011FixProductAdded>()
.From<Chr0011FixProductRestocked>();
}
}

Chronicle routes events from a single event store to each observer. A projection that declares fluent builder calls referencing events from different stores would require Chronicle to multiplex subscriptions, which the observer model does not support. This rule catches the misconfiguration at compile time instead of failing when the client connects.

Split projections that genuinely need to project events from different stores into one projection per store, each subscribing to its own event stream.

  • CHR0008: Reactor event types must be from the same event store — the same contract for reactors.
  • CHR0009: Reducer event types must be from the same event store — the same contract for reducers.
  • CHR0010: Model-bound projection event types must be from the same event store — the same contract for model-bound projections.