Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 937
sanket bisne Avatar asked Nov 18 '25 13:11

sanket bisne


1 Answers

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.

like image 190
Paweł Rozumek Avatar answered Nov 20 '25 01:11

Paweł Rozumek