I'm buiding endpoints with FastAPI, PostgreSQL as database, and the driver is asyncpg associated with SQLAlchemy for asynchronous. As mentioned in the title, I'm having trouble with async_sessionmaker, it keeps showing: 'async_sessionmaker' object does not support the asynchronous context manager protocol. Here the part of code in repository: class GenreRepositoryImpl(GenreRepository): def __init__(self, sessionmaker: async_sessionmaker[AsyncSession]): self._sessionmaker = sessionmaker async def create(self, genre: Genre) -> Genre: genre_entity = GenreEntityMappers.from_domain(genre) async with self._sessionmaker() as session: session.add(genre_entity) await session.commit() await session.refresh(genre_entity) return GenreEntityMappers.to_domain(genre_entity) Somehow it works when I use it as transaction with begin(), I don't understand what's wrong. Continue reading...