PrismaP
Prisma12mo ago
4 replies
C0casio45

Many to two relation

Hey,
I have these model
model a {
  id        String         @id @default(cuid())
  b1        b              @relation(fields: [b1Id], references: [id]) <- ERR
  b2        b              @relation(fields: [b2Id], references: [id])

  b1Id      String
  b2Id      String
}
model b {
  id        String         @id @default(cuid())
  a1        a              @relation(fields: [a1Id], references: [id])
  a2        a              @relation(fields: [a2Id], references: [id])

  a1Id      String
  a2Id      String
}


the ERR is
Error validating model "a": Ambiguous relation detected. The fields `b1` and `b2` in model `a` both refer to `b`. Please provide different relation names for them by adding `@relation(<name>).
Was this page helpful?