title: Getting RepositoryNotFoundError in typeorm but I'm pretty sure they are registered
body: <p>I'm writing an app using Next.js + TypeORM and running in to an issue with the integration.</p>
  <blockquote>
  <p>RepositoryNotFoundError: No repository for &quot;User&quot; was found. Looks like this entity is not registered in current &quot;default&quot; connection?</p>
  </blockquote>
  <p>From what I can tell I have everything configured correctly but continue to get this error. I've debugged and inspected the active connection and see the entities on <code>connection.options.entities</code> so they are registered. Really stumped by this one.</p>
  <p>Repo: <a href="https://github.com/kyleect/bolt" rel="nofollow noreferrer">https://github.com/kyleect/bolt</a></p>
  <p>Server:</p>
  <pre class="lang-js prettyprint-override"><code>import &quot;reflect-metadata&quot;;
  
  import { createServer } from &quot;http&quot;;
  import { parse } from &quot;url&quot;;
  import { createConnection } from &quot;typeorm&quot;;
  import path from &quot;path&quot;;
  import next from &quot;next&quot;;
  
  import { Link } from &quot;../entities/Link&quot;;
  import { Post } from &quot;../entities/Post&quot;;
  import { User } from &quot;../entities/User&quot;;
  
  const dev = process.env.NODE_ENV !== &quot;production&quot;;
  const app = next({ dev });
  const handle = app.getRequestHandler();
  
  app
    .prepare()
    .then(() =&gt;
      createConnection({
        type: &quot;sqlite&quot;,
        database: &quot;local.db&quot;,
        synchronize: true,
        logging: true,
        entities: [Link, Post, User],
      })
    )
    .then(() =&gt; {
      createServer((req, res) =&gt; {
        handle(req, res, parse(req.url, true));
      }).listen(3000, () =&gt; {
        console.log(&quot;&gt; Ready on http://localhost:3000&quot;);
      });
    });
  </code></pre>
  <p>One of the endpoint handlers. There is a similar one for all of them and they all throw an error:</p>
  <pre class="lang-js prettyprint-override"><code>const db = await getConnection();
  
  const repo = db.getRepository(User);
  
  const users = await repo.find();
  
  res.json(users);
  </code></pre>
  <p>Entities:</p>
  <pre class="lang-js prettyprint-override"><code>import {
    Entity,
    Column,
    PrimaryGeneratedColumn,
    OneToMany,
    CreateDateColumn,
    UpdateDateColumn,
    DeleteDateColumn,
  } from &quot;typeorm&quot;;
  import { Post } from &quot;./Post&quot;;
  
  @Entity()
  export class Link {
    @PrimaryGeneratedColumn(&quot;uuid&quot;)
    id: string;
  
    @CreateDateColumn()
    createdDate: Date;
  
    @UpdateDateColumn()
    updatedDate: Date;
  
    @DeleteDateColumn()
    deletedDate: Date;
  
    @Column({ type: &quot;varchar&quot; })
    url: string;
  
    @OneToMany((type) =&gt; Post, (post) =&gt; post.link)
    posts: Array&lt;Post&gt;;
  }
  </code></pre>
  <pre class="lang-js prettyprint-override"><code>import {
    Entity,
    Column,
    PrimaryGeneratedColumn,
    ManyToOne,
    CreateDateColumn,
    UpdateDateColumn,
    DeleteDateColumn,
  } from &quot;typeorm&quot;;
  import { User } from &quot;./User&quot;;
  import { Link } from &quot;./Link&quot;;
  
  @Entity()
  export class Post {
    @PrimaryGeneratedColumn(&quot;uuid&quot;)
    id: string;
  
    @CreateDateColumn()
    createdDate: Date;
  
    @UpdateDateColumn()
    updatedDate: Date;
  
    @DeleteDateColumn()
    deletedDate: Date;
  
    @ManyToOne((type) =&gt; User, (user) =&gt; user.posts)
    user: User;
  
    @Column({ type: &quot;varchar&quot; })
    title: string;
  
    @Column({ type: &quot;varchar&quot; })
    body: string;
  
    @ManyToOne((type) =&gt; Link, (link) =&gt; link.posts)
    link: Link;
  }
  </code></pre>
  <pre class="lang-js prettyprint-override"><code>import {
    Entity,
    Column,
    PrimaryGeneratedColumn,
    OneToMany,
    DeleteDateColumn,
    UpdateDateColumn,
    CreateDateColumn,
  } from &quot;typeorm&quot;;
  import { Post } from &quot;./Post&quot;;
  
  @Entity()
  export class User {
    @PrimaryGeneratedColumn(&quot;uuid&quot;)
    id: string;
  
    @CreateDateColumn()
    createdDate: Date;
  
    @UpdateDateColumn()
    updatedDate: Date;
  
    @DeleteDateColumn()
    deletedDate: Date;
  
    @Column({ type: &quot;varchar&quot; })
    username: string;
  
    @OneToMany((type) =&gt; Post, (post) =&gt; post.user)
    posts: Array&lt;Post&gt;;
  }
  </code></pre>