Ecto, Contexts and Naming References

From the docs at Ecto.Schema — Ecto v3.14.0

:foreign_key - Sets the foreign key, this should map to a field on the other schema, defaults to the underscored name of the current schema suffixed by _id

So by default it will be “todo_list_id”, as that’s the schema name (I would actually expect todo_lists_id?). so you either need to change that “i.list_id” to “i.todo_list_id” in your query or else manually set what the primary key name is in your scheme to just be list_id .. I would do the former, though, as then you don’t have to keep remembering to do this :slight_smile: