CodeLens is not available in the Community editions. You need Professional or higher to switch it on.
In VS2015, one way to "get" CodeLens was to install the SQL Server Developer Tools (SSDT) but I believe this has been rectified in VS2017.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…