Repository Not Found Error in TypeScript, when I was connecting to MySQL through the typeorm it was encountering the error

2.9k Views Asked by At

The server is listening on 3000. My MySQL database is initialized.

RepositoryNotFoundError: No repository for "User" was found. 
  Looks like this entity is not registered in current "default" connection?

message: 'No repository for "User" was found. Looks like tes.js) 
{his entity is not registered in current "default" connection?'                 
 his entity is not registered in current "default" connection?'}

How can I fix this?

1

There are 1 best solutions below

0
Paweł Rozumek On

I encountered same problem, You might be trying to use method getRepository before database connection is established.

I solved this problem by using inside async function const connection = await createConnection() then await connection.driver.afterConnect().then() and then stuff like routes.