Prisma ORM 8 is here.Read the docs

Editor support

What the Prisma VS Code extension does for a Prisma ORM contract, and what to do when it stops accepting the file.

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 file header

The extension only works on .prisma files whose first non-blank line is:

prisma/contract.prisma
// use prisma-8

A 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.

What the editor does

  • 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 writes contract.json and contract.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 as sort and Desc in @@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. In a block such as policy_select, it completes the values, including inside lists and function calls, and offers ns. for a namespace. A block value can name an entity in another namespace, as in target = auth.Account.
  • Hover shows what a name is. Over a model, field, type, or block, it shows the declaration and its /// doc comment. Over an attribute, argument name, function, constant, or a type from an extension pack, it shows the signature and its documentation.
  • Go to definition jumps from a use of a name to its declaration, and Find references lists every place a name is used. Both work for models, composite types, named types, blocks, fields, and namespaces, across every file of the contract.
  • 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.

A contract in several files

When contract in prisma.config.ts is a glob, such as ./*.prisma, the editor reads every matching file that starts with // use prisma-8 as one contract, the same files that prisma contract emit reads. A model declared in a file you have not opened is known in the files you edit, and the editor reports the errors in every file of the contract, including the ones you have not opened. See Split the schema across several files.

False errors after an upgrade

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:

Terminal
npm ls @prisma/orm-postgres

If it prints a version below 8.0.0-rc.9, update it to the latest version:

Terminal
bun add @prisma/orm-postgres@latest

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.

On this page