title: 'SQLite Error: No Such Table' with TypeORM on a connected DB with other tables accessible. Is there a specific way to reach tables with foreign keys?
body: <p>Good evening all,</p>
  
  <p>I am trying to query on a table called 'MessageEntityXREF' stored on a sqlite DB through TypeORM.</p>
  
  <p>The database is connected and other tables are reachable.</p>
  
  <p>When I try to Get on this specific table:
  "QueryFailedError: SQLITE_ERROR: no such table: message_entity_xref" </p>
  
  <p>Any help or advice would be greatly appreciated.</p>
  
  <p>Thanks</p>
  
  <p>I tried to change the order in the constructor, changed the typing.
  However, considering the same method works for other tables, I tend to think there is an issue with this table.
  I queried the sqlite db for a list of all tables, it gives a list with the MessageEntityXREF in it.
  I installed DB browser for SQLite and the table is here with the MessageID and EntityId columns.</p>
  
  <p>NOTE: there is a table called "Entities" in the database which could lead to confusion with TypeORM tendency to use @Entity etc...</p>
  
  <p>With nestJS, I created an entity for this table and I inject the repository in a custom service used then by a function which find in this repository:</p>
  
  <p>Messages Service</p>
  
  <pre><code>@Entity export class MessageEntityXREF {
  
  @PrimaryColumn() MessageId: number;
  
   @Column() EntityID: number; } 
  
  
  custom service
  
  @InjectRepository(MessageEntityXREF)
  private readonly messageEntityRepository: Repository&lt;                 MessageEntityXREF&gt;
  
  async getMessagesByEntityId(id: number): Promise&lt;any[]&gt; {
  try {
    return await this.messageEntityRepository.find({
      select: ['MessageId','EntityId'],
      where: [
      { EntityId: id}
      ]
   });
  } catch (error) {
    throw error;
    }
   }
  }
  </code></pre>
  
  <p>I would expect a list of all MessageId with a given EntityID.</p>
  
  <p>When no ID is given, I get an empty array (expected).</p>
  
  <p>When I give an ID, I get a 500 error from the server with "QueryFailedError: SQLITE_ERROR: no such table: message_entity_xref"</p>
  
  <p>Definition of entity</p>
  
  <pre><code>import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm';
  
  @Entity()
  export class MessageEntityXREF {
    @PrimaryGeneratedColumn()
    MessageId: number;
  
    @Column()
    EntityId: number;
  }
  </code></pre>
  
  <p>Messages Module</p>
  
  <pre><code>@Module({
    imports: [
      CacheModule.register(),
      TypeOrmModule.forFeature([Messages, MessageEntityXREF]),
    ],
    providers: [MessagesService, MessagesResolver],
    controllers: [MessagesController],
  })
  export class MessagesModule {}
  </code></pre>
  
  <p>and the ormconfig.json</p>
  
  <pre><code>{
    "skip": false,
    "name": "default",
    "type": "sqlite",
    "database": "./sqliteDB/solve.rld",
    "entities": ["src/**/**.entity{.ts,.js}"],
    "logging": false
  }
  </code></pre>