Skip to main content

Create Entity Model

Creates a model class for a specific entity in the .NET application.

Event Name

CreateEntityModel

Event Params

export interface CreateEntityModelParams extends EventParams {
entity: Entity;
entities: Entity[];
resourceName: string;
apisDir: string;
}

Example

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;
}