Fix: Ensure that database instances are attached to the current
SQLAlchemy session before accessing properties