I've figured out a solution. The problem was in the new version of Microsoft.EntityFrameworkCore (version 9). When I set it to version 8.0.10 across my projects, migrations started working again.
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />