I have a database with a lot of data…. that was being handled by Dot Net core framework.
Now i want a small admin panel using nextjs i want to connect that database with my new next js application using Prisma.
But without schema Prisma won’t work.
anyone please explain what is the best way to do it.
I have tried db. pull it creates schema but when i access that schema with Prisma client. it shows error.
const user = await prisma.post.findFirst({ where: { name: "ali" } });
your textenter image description here
2
Answers
If you want to use Prisma without defining a schema, I think you can take advantage of Prisma’s
prisma.$queryRaw
method, which allows you to send raw SQL queries directly to the database. This way, you can interact with the database without defining Prisma models.I add example code.
Try using queryRaw method to execute raw SQL queries against your PostgreSQL database. In your case, hope it’ll work.
Or you can also consider creating prisma schema from your existing database using these commands