Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.amplication.com/llms.txt

Use this file to discover all available pages before exploring further.

Event Name

CreateEntityModel

Event Parameters

entity
Entity
The entity object for which the model class is being created.
entities
Entity[]
An array of all entities in the application.
resourceName
string
The name of the resource (typically the entity name).
apisDir
string
The directory where the API related files are being generated.
afterCreateEntityModel(
  context: dotnetTypes.DsgContext,
  eventParams: dotnet.CreateEntityModelParams,
  files: FileMap<Class>
): Promise<FileMap<Class>> {
  const { entity, resourceName } = eventParams;
  const modelFile = files.get(`${resourceName}/Models/${entity.name}.cs`);
  if (modelFile) {
    modelFile.code.addAttribute(
      CsharpSupport.attribute({
        name: "Table",
        arguments: [`"${entity.name}s"`],
      })
    );
  }
  return files;
}