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

CreateSeedDevelopmentDataFile

Event Parameters

seedFilePath
string
The full path to the seed development data file being created.
resourceName
string
The name of the resource (typically the application name).
afterCreateSeedDevelopmentDataFile(
  context: dotnetTypes.DsgContext,
  eventParams: dotnet.CreateSeedDevelopmentDataFileParams,
  files: FileMap<Class>
): FileMap<Class> {
  const { seedFilePath, resourceName } = eventParams;
  const { entities } = context;

  if (!entities) return files;

  const seedFile = files.get(seedFilePath);
  seedFile?.code.addMethod(
    CsharpSupport.method({
      name: "SeedDevUser",
      access: "public",
      isAsync: true,
      body: CreateSeedDevelopmentDataBody(resourceName, context),
      type: MethodType.STATIC,
      parameters: [
        CsharpSupport.parameter({
          name: "serviceProvider",
          type: CsharpSupport.Types.reference(
            CsharpSupport.classReference({
              name: "IServiceProvider",
              namespace: `${resourceName}.Infrastructure.Models`,
            })
          ),
        }),
        CsharpSupport.parameter({
          name: "configuration",
          type: CsharpSupport.Types.reference(
            CsharpSupport.classReference({
              name: "IConfiguration",
              namespace: "",
            })
          ),
        }),
      ],
    })
  );

  return files;
}