---
title: 'CHR0001: Event type must have [EventType] attribute'
---

## Rule Description

Types that are appended to event sequences must be marked with the `[EventType]` attribute. This ensures that all events in the event store are properly identified and can be correctly deserialized.

## Severity

Error

## Example

### Violation

```csharp
// Missing [EventType] attribute
public record UserCreated(string Username, string Email);

public class UserService
{
    private readonly IEventSequence _eventSequence;

    public async Task CreateUser(string username, string email)
    {
        // CHR0001: Type 'UserCreated' must be marked with [EventType] attribute
        await _eventSequence.Append(
            eventSourceId: userId,
            @event: new UserCreated(username, email));
    }
}
```

### Fix

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

[EventType]
public record UserCreated(string Username, string Email);

public class UserService
{
    private readonly IEventSequence _eventSequence;

    public async Task CreateUser(string username, string email)
    {
        // Now valid
        await _eventSequence.Append(
            eventSourceId: userId,
            @event: new UserCreated(username, email));
    }
}
```

## Quick Fix

The analyzer provides a code fix that automatically:
1. Adds the `[EventType]` attribute to the event type
2. Adds the required using directive if not already present

## Why This Rule Exists

The `[EventType]` attribute is crucial for Chronicle's event handling:
- It uniquely identifies the event type in the event store
- It enables proper event serialization and deserialization
- It allows Chronicle to track event type generations and schemas
- It ensures type safety when working with events

## Related Rules

- [CHR0003](/chronicle/code-analysis/chr0003/): Model bound projection attributes
- [CHR0005](/chronicle/code-analysis/chr0005/): Reactor event parameters
- [CHR0007](/chronicle/code-analysis/chr0007/): Reducer event parameters
