Table of Contents

Entity

Entities are defined in the Domain layer. They are the starting point for defining the structure of a module.

An entity describes a set of :

  • Properties (scalar properties, references and collections)
  • Validation rules
  • Event rules

An entity corresponds to a C# class that can eventually be mapped to a database table. This class includes a set of properties.

The primary key

A primary key is a unique identifier for each record in a database table. It is essential for ensuring data integrity and enabling efficient search, sort, and reference operations. Here are some types of primary keys:

  1. Simple Primary Key: A single column is used as the primary key. For example, a unique ID in a User table.

  2. Composite Primary Key: Multiple columns are used to form the primary key. For example, in an Order table, the UserID and OrderID columns can be combined to form a primary key.

In addition to these, primary keys can also be of different types based on the data type of the primary key column:

  • AutoIncrement: This is the default type recommended by Neos. A numeric primary key that automatically increments for each new record. This is a common type.

  • Guid: A primary key that uses a globally unique identifier (GUID). This is useful when you need to generate unique IDs in a distributed system.

  • String: A primary key that uses a string. In specific case or existing database. The key can be initialized in entity saving rule for example. See this article to configure entity, entity view and UI view

The choice of primary key type depends on the specific needs of your application and database.

See also