> For the complete documentation index, see [llms.txt](https://briebug.gitbook.io/ngrx-auto-entity/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://briebug.gitbook.io/ngrx-auto-entity/getting-started/from-scratch/entity-model.md).

# Entity Model

In a departure from classic @ngrx/entity models, each model in your application should be defined as a **class** (see note below). Here is an example of a `Customer` model:

{% code title="customer.model.ts" %}

```typescript
import { Entity, Key } from '@briebug/ngrx-auto-entity';

@Entity({
  modelName: 'Customer',
  uriName: 'customers'
})
export class Customer {
  @Key id: number;
  name: string;
  catchPhrase: string;
}
```

{% endcode %}

Next we need to import the `Key` and `Entity` decorators. The `Key` decorator is used to specify the property in your model that is the unique identifier. Decorate the `id` property, which is the unique identifier for `Customer` model. Read more about entity keys in the advanced documentation.

The `Entity` decorator is used to attach metadata to your entity model that the NgRx Auto-Entity library can use to perform many of its automated tasks. In version 0.5 of the library, only the `modelName` must be specified. Read more about the entity decorator in the advanced documentation.

{% hint style="warning" %}
Note that the model *must* be a **class** and **not an interface**. This is because interfaces are a *compile-time only* feature of TypeScript, while classes are a native *runtime* construct in JavaScript. Further, the `modelName` *must* be defined on the entity, as this is the name that the library will use at runtime for minified/uglified code (critical, read more in advanced documentation.)
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://briebug.gitbook.io/ngrx-auto-entity/getting-started/from-scratch/entity-model.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
