Problem with Primary Key ambiente_id instead of id in Typeorm

Asked

Viewed 28 times

1

I am trying to create a table in the Mysql database, with Typeorm where the id is ambiente_id (nome da tabela + _ + id).

Error:

ER_WRONG_AUTO_KEY: Incorrect table Definition; there can be only one auto column and it must be defined as a key code: 'ER_WRONG_AUTO_KEY', Rrno: 1075, sqlMessage: 'Incorrect table Definition; there can be only one auto column and it must be defined as a key', sqlState: '42000', index: 0, sql: 'ALTER TABLE ambiente ADD id int NOT NULL AUTO_INCREMENT'

My entity:

@Entity()
export class Ambiente {
   @PrimaryGeneratedColumn({name: 'ambiente_id'})
   ambiente_id: number;

My database config is with synchronize: true.

  • the error was that it was building on top of the /dist folder, not removing and rebuilding, only rebuilding on top of the folder already created there was error.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.