title: How to fix Prisma Client getting undefined for custom model
body: <p>I generated a project from <a href="https://www.npmjs.com/package/typescript-express-starter" rel="nofollow noreferrer" title="Typescript Express Starter Project">typescript-express-starter</a> and selected <a href="https://www.prisma.io/" rel="nofollow noreferrer">Prisma</a> as the ORM.
  The basic 'User' model generated by the starter project is working fine. I created a model 'Product' as the existing 'User' model. I added it in <a href="https://i.stack.imgur.com/vMFsH.png" rel="nofollow noreferrer">schema.prisma</a> and created a products.services.ts.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="true">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import { PrismaClient, Product } from '@prisma/client';
  import { CreateProductDto } from '@dtos/products.dto';
  import HttpException from '@exceptions/HttpException';
  import { isEmpty } from '@utils/util';
  
  class ProductService {
    public products = new PrismaClient().product;
  
    public async findAllProducts(): Promise&lt;Product[]&gt; {
      const allProducts: Product[] = await this.products.findMany();
      return allProducts;
    }
  
    
  }
  
  export default ProductService;</code></pre>
  </div>
  </div>
  </p>
  <p>The problem is while the <strong>PrismaClient().user</strong> is returning a prisma model but <strong>PrismaClient().product</strong> is returning undefined. The generated PrismaClient typescript files have the products model and associated methods and it is also showing in the VS Code hints. However when running the project PrismaClient().products is returning undefined instead of the actual model. When running the prisma studio, it is showing the models.</p>
  <p><a href="https://i.stack.imgur.com/S6wth.png" rel="nofollow noreferrer">Products Model - Failed API Request</a></p>
  <p><a href="https://i.stack.imgur.com/zoMaY.png" rel="nofollow noreferrer">Users Model - Successful API Request</a></p>
  <p><a href="https://i.stack.imgur.com/jnqyu.png" rel="nofollow noreferrer">Prisma Models in Studio</a></p>
  <p><a href="https://i.stack.imgur.com/NC7X6.png" rel="nofollow noreferrer">User Model in Prisma Studio</a></p>
  <p><a href="https://i.stack.imgur.com/YwImx.png" rel="nofollow noreferrer">Products Model in Prisma Studio</a></p>
  <p>I could not find any solution from the available documentation or forums. My most probable guess is that I am missing some configuration or files that need to be added to work. But I don't know where and what that could be. Please help out.</p>
  <p>This is the log of <strong>new PrismaClient()</strong>.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>server        | PrismaClient:  &lt;ref *1&gt; NewPrismaClient [PrismaClient] {
  server        |   _middlewares: [],
  server        |   _engineMiddlewares: [],
  server        |   _transactionId: 1,
  server        |   _rejectOnNotFound: undefined,
  server        |   _clientVersion: '2.23.0',
  server        |   _activeProvider: 'mysql',
  server        |   _errorFormat: 'colorless',
  server        |   _dmmf: DMMFClass {
  server        |     outputTypeToMergedOutputType: [Function (anonymous)],
  server        |     datamodel: { enums: [], models: [Array] },
  server        |     schema: {
  server        |       inputObjectTypes: [Object],
  server        |       outputObjectTypes: [Object],
  server        |       enumTypes: [Object]
  server        |     },
  server        |     mappings: { modelOperations: [Array], otherOperations: [Object] },
  server        |     enumMap: { UserScalarFieldEnum: [Object], SortOrder: [Object] },
  server        |     datamodelEnumMap: {},
  server        |     queryType: {
  server        |       name: 'Query',
  server        |       fields: [Array],
  server        |       isEmbedded: false,
  server        |       fieldMap: [Object]
  server        |     },
  server        |     mutationType: {
  server        |       name: 'Mutation',
  server        |       fields: [Array],
  server        |       isEmbedded: false,
  server        |       fieldMap: [Object]
  server        |     },
  server        |     modelMap: { User: [Object] },
  server        |     outputTypes: { model: [Array], prisma: [Array] },
  server        |     outputTypeMap: {
  server        |       User: [Object],
  server        |       Query: [Object],
  server        |       Mutation: [Object],
  server        |       AggregateUser: [Object],
  server        |       UserGroupByOutputType: [Object],
  server        |       AffectedRowsOutput: [Object],
  server        |       UserCountAggregateOutputType: [Object],
  server        |       UserAvgAggregateOutputType: [Object],
  server        |       UserSumAggregateOutputType: [Object],
  server        |       UserMinAggregateOutputType: [Object],
  server        |       UserMaxAggregateOutputType: [Object]
  server        |     },
  server        |     inputObjectTypes: { prisma: [Array] },
  server        |     inputTypeMap: {
  server        |       UserWhereInput: [Object],
  server        |       UserOrderByInput: [Object],
  server        |       UserWhereUniqueInput: [Object],
  server        |       UserScalarWhereWithAggregatesInput: [Object],
  server        |       UserCreateInput: [Object],
  server        |       UserUncheckedCreateInput: [Object],
  server        |       UserUpdateInput: [Object],
  server        |       UserUncheckedUpdateInput: [Object],
  server        |       UserCreateManyInput: [Object],
  server        |       UserUpdateManyMutationInput: [Object],
  server        |       UserUncheckedUpdateManyInput: [Object],
  server        |       IntFilter: [Object],
  server        |       StringFilter: [Object],
  server        |       IntWithAggregatesFilter: [Object],
  server        |       StringWithAggregatesFilter: [Object],
  server        |       StringFieldUpdateOperationsInput: [Object],
  server        |       IntFieldUpdateOperationsInput: [Object],
  server        |       NestedIntFilter: [Object],
  server        |       NestedStringFilter: [Object],
  server        |       NestedIntWithAggregatesFilter: [Object],
  server        |       NestedFloatFilter: [Object],
  server        |       NestedStringWithAggregatesFilter: [Object]
  server        |     },
  server        |     mappingsMap: { User: [Object] },
  server        |     rootFieldMap: {
  server        |       findFirstUser: [Object],
  server        |       findManyUser: [Object],
  server        |       aggregateUser: [Object],
  server        |       groupByUser: [Object],
  server        |       findUniqueUser: [Object],
  server        |       createOneUser: [Object],
  server        |       upsertOneUser: [Object],
  server        |       createManyUser: [Object],
  server        |       deleteOneUser: [Object],
  server        |       updateOneUser: [Object],
  server        |       updateManyUser: [Object],
  server        |       deleteManyUser: [Object],
  server        |       executeRaw: [Object],
  server        |       queryRaw: [Object]
  server        |     }
  server        |   },
  server        |   _previewFeatures: [],
  server        |   _engineConfig: {
  server        |     cwd: '/app/src/prisma',
  server        |     dirname: '/app/node_modules/.prisma/client',
  server        |     enableDebugLogs: false,
  server        |     enableEngineDebugMode: undefined,
  server        |     datamodelPath: '/app/node_modules/.prisma/client/schema.prisma',
  server        |     prismaPath: undefined,
  server        |     engineEndpoint: undefined,
  server        |     datasources: [],
  server        |     generator: {
  server        |       name: 'client',
  server        |       provider: [Object],
  server        |       output: [Object],
  server        |       config: {},
  server        |       binaryTargets: [],
  server        |       previewFeatures: []
  server        |     },
  server        |     showColors: false,
  server        |     logLevel: undefined,
  server        |     logQueries: undefined,
  server        |     env: {
  server        |       PORT: '3000',
  server        |       DATABASE_URL: 'mysql://root:password@mysql:3306/prisma'
  server        |     },
  server        |     flags: [],
  server        |     clientVersion: '2.23.0',
  server        |     previewFeatures: [],
  server        |     useUds: undefined,
  server        |     activeProvider: 'mysql'
  server        |   },
  server        |   _engine: NodeEngine {
  server        |     startCount: 0,
  server        |     previewFeatures: [],
  server        |     useUds: false,
  server        |     stderrLogs: '',
  server        |     handleRequestError: [AsyncFunction (anonymous)],
  server        |     dirname: '/app/node_modules/.prisma/client',
  server        |     env: {
  server        |       PORT: '3000',
  server        |       DATABASE_URL: 'mysql://root:password@mysql:3306/prisma'
  server        |     },
  server        |     cwd: '/app/src/prisma',
  server        |     enableDebugLogs: false,
  server        |     enableEngineDebugMode: false,
  server        |     datamodelPath: '/app/node_modules/.prisma/client/schema.prisma',
  server        |     prismaPath: undefined,
  server        |     generator: {
  server        |       name: 'client',
  server        |       provider: [Object],
  server        |       output: [Object],
  server        |       config: {},
  server        |       binaryTargets: [],
  server        |       previewFeatures: []
  server        |     },
  server        |     datasources: [],
  server        |     logEmitter: EventEmitter {
  server        |       _events: [Object: null prototype],
  server        |       _eventsCount: 1,
  server        |       _maxListeners: undefined,
  server        |       [Symbol(kCapture)]: false
  server        |     },
  server        |     showColors: false,
  server        |     logLevel: undefined,
  server        |     logQueries: false,
  server        |     clientVersion: '2.23.0',
  server        |     flags: [],
  server        |     activeProvider: 'mysql',
  server        |     engineEndpoint: undefined,
  server        |     platformPromise: Promise { &lt;pending&gt; },
  server        |     getConfigPromise: Promise { &lt;pending&gt; }
  server        |   },
  server        |   _fetcher: PrismaClientFetcher {
  server        |     prisma: [Circular *1],
  server        |     debug: false,
  server        |     hooks: undefined,
  server        |     dataloader: Dataloader { options: [Object], tickActive: false, batches: {} }
  server        |   },
  server        |   user: {
  server        |     findUnique: [Function (anonymous)],
  server        |     findFirst: [Function (anonymous)],
  server        |     findMany: [Function (anonymous)],
  server        |     create: [Function (anonymous)],
  server        |     createMany: [Function (anonymous)],
  server        |     delete: [Function (anonymous)],
  server        |     update: [Function (anonymous)],
  server        |     deleteMany: [Function (anonymous)],
  server        |     updateMany: [Function (anonymous)],
  server        |     upsert: [Function (anonymous)],
  server        |     count: [Function (anonymous)],
  server        |     aggregate: [Function (anonymous)],
  server        |     groupBy: [Function (anonymous)]
  server        |   }
  server        | }</code></pre>
  </div>
  </div>
  </p>