TypeORM Error during Data Source initialization TypeORMError

Wonhee Rhyu·2023년 7월 28일

Concert_date 엔티티를 새로 만든 후 서버를 실행시키니

Error during Data Source initialization TypeORMError: Entity metadata for Concert#concert_dates was not found. Check if you specified a correct entity object and if it's connected in the connection options.

에러 발생
보니까 data_source.ts에서 Concer_data 엔티티를 못가져와서 생긴 에러였음

export const AppDataSource = new DataSource({
  type: 'mysql',
  host: 'localhost',
  port: 3306,
  username: 'root',
  password: 'dlsvmfjs27!',
  database: 'ticket-reservation',
  synchronize: true,
  logging: true,
  entities: [User, Concert, Reservation],
  migrations: [],
  subscribers: [],
});

이부분에서 entities에 새로 생성한 엔티티 클래스 이름을 넣어주던지

{
    "type": "mysql",
    "host": "localhost",
    "port": 3306,
    "username": "blahblah",
    "password": "blahblah",
    "database": "blahblah",
    "synchronize": true,
    "logging": false,
    "entities": [
       "entity/*.js"
    ]
 }

이렇게 모든 엔티티를 전부 불러오게 수정해주면 해결됨

profile
공부하면서 어려웠던 것들 정리

0개의 댓글