---
title: 'CHR0003: Model bound projection attribute must reference event type with [EventType] attribute'
---

## Rule Description

Model bound projection attributes (such as `FromEventAttribute<TEvent>`, `RemovedWithAttribute<TEvent>`, etc.) must reference types that are marked with the `[EventType]` attribute.

## Severity

Error

## Example

### Violation

```csharp
// Missing [EventType] attribute
public record ProductAdded(Guid ProductId, string Name, decimal Price);

// CHR0003: Type 'ProductAdded' must be marked with [EventType] attribute
[FromEvent<ProductAdded>]
public class ProductReadModel
{
    public Guid Id { get; set; }
    public string Name { get; set; }
    public decimal Price { get; set; }
}
```

### Fix

```csharp
using Cratis.Chronicle.Concepts.Events;

[EventType]
public record ProductAdded(Guid ProductId, string Name, decimal Price);

// Now valid
[FromEvent<ProductAdded>]
public class ProductReadModel
{
    public Guid Id { get; set; }
    public string Name { get; set; }
    public decimal Price { get; set; }
}
```

## Applicable Attributes

This rule applies to the following model bound projection attributes:
- `FromEventAttribute<TEvent>`
- `RemovedWithAttribute<TEvent>`
- `RemovedWithJoinAttribute<TEvent>`
- `JoinAttribute<TEvent>`
- `ChildrenFromAttribute<TEvent>`
- `FromEveryAttribute<TEvent>`

## Quick Fix

The analyzer provides a code fix that automatically adds the `[EventType]` attribute to the referenced event type.

## Why This Rule Exists

Model bound projections use attributes to define how events map to read models. These attributes must reference valid event types to ensure:
- Proper event-to-model mapping
- Correct projection materialization
- Type-safe projection definitions
- Accurate event handling

## Related Rules

- [CHR0001](/chronicle/code-analysis/chr0001/): Event sequence append operations
- [CHR0002](/chronicle/code-analysis/chr0002/): Declarative projection event types
