# X_ENTITY_COUNTS_INVALID

## Means

references(…, { countedIn }) names no integer of its parent, or is no key to its primary key

## Typical cause

a counter is an integer the database keeps on the parent, from a child key that references() that parent's primary key

## Fix

`x db gen "count likes"` after `postId: uuid().references(() => posts.id, { countedIn: () => posts.likeCount })`, with `likeCount: integer().default(0)` on posts

[Entity and database](/error-codes#entity-and-database)
