Ex_admin foreign key issue

There is a many-to-many association between users. It describes follower-following relationships.

MyApp.User module contains:

has_many :connections, MyApp.Connection
has_many :followings, through: [:connections, :following], foreign_key: :following_id
has_many :followers, through: [:connections, :follower], foreign_key: :follower_id

MyApp.Connection module contains:

belongs_to :follower, User, foreign_key: :follower_id
belongs_to :following, User, foreign_key: :following_id

Ex_admin tries to query:

Request: GET /admin/users
** (exit) an exception was raised:
    ** (Ecto.QueryError) deps/ecto/lib/ecto/association.ex:501: field `MyApp.Connection.user_id` in `where` does not exist in the schema in query:

from c in MyApp.Connection,
  where: c.user_id in ^["03cbcd21-dc1a-4615-b2a3-3ee432884a19", "06c32749-a57a-4e78-b77a-e98d9fa11348"],
  order_by: [asc: c.user_id],
  select: {c.user_id, c}

So ex_admin doesn’t respect foreign key. Possible solutions?

It works when like this, but this is definitely incorrect
has_many :connections, MyApp.Connection, foreign_key: :following_id