Editor support
Install the Prisma VS Code extension to get error checking, formatting, and completion in your .prisma file.
In Prisma ORM 8 that file is the data contract: the description of your models that Prisma ORM 7 called the schema. Its path is the contract setting in your prisma.config.ts, which is prisma/contract.prisma in the config orm init writes; see Configuration.
Coming from Prisma ORM 7? Start with Coming from Prisma ORM 7. This page covers VS Code only.
The extension only works on .prisma files whose first non-blank line is:
// use prisma-8A file without that line gets no error checking, no completion, and no formatting. prisma contract emit also skips it without a warning, and when none of the files that the contract setting names has the line, contract emit fails with CONTRACT.SOURCE_LOAD_FAILED. orm init and contract infer write the line for you. Add it yourself when you create a contract by hand.
- Errors appear inline as you type. They are the same errors you would get from
prisma contract emit, the command that checks the contract and writescontract.jsonandcontract.d.ts. - Formatting reformats the whole file. In VS Code, run Format Document.
- Completion starts when you type
@or@@. The editor lists attribute names such as@id,@default, and@@index, each with a short description. Inside an attribute, it lists the names of the arguments you have not filled in yet and suggests values for them. It also suggests values inside[ ]and{ }. In a MongoDB index's field list, it suggests the option and its values in the parentheses after a field name, such assortandDescin@@index([createdAt(sort: Desc)]). Where an attribute expects a field name, it suggests only scalar fields. When an attribute has required arguments, VS Code inserts them as placeholders named after each argument, which you tab through. - Signature help appears when you type
(or,inside an attribute. It shows the attribute's arguments and describes the one you are typing.
The list of attributes comes from your prisma.config.ts: the database it declares and the Prisma extension packs listed under extensions; see Extension packs for that config. Extension packs are add-on packages for database features such as pgvector. If your config lists the pgvector pack, the editor also suggests pgvector's attributes. No database connection is needed.
If the editor marks attributes as errors in a contract that prisma contract emit accepts, the likely cause is an old ORM package. That is the @prisma/orm-postgres, @prisma/orm-mongo, or @prisma/orm-sqlite package your project installs for its database. Check the installed version:
npm ls @prisma/orm-postgresIf it prints a version below 8.0.0-rc.9, update it to the current release:
bun add @prisma/orm-postgres@latestpnpm add @prisma/orm-postgres@latestyarn add @prisma/orm-postgres@latestnpm install @prisma/orm-postgres@latestReplace orm-postgres with orm-mongo or orm-sqlite to match your database. Then reload the editor window. In VS Code, run Developer: Reload Window from the Command Palette.
Replace orm-postgres with orm-mongo or orm-sqlite to match your database. Then reload the editor window. In VS Code, run Developer: Reload Window from the Command Palette.