You can use AspNetCore.Totp.
https://github.com/damirkusar/AspNetCore.Totp
It works exactly like GoogleAuthenticator, have a look at the Tests project for the implementation (really simple).
You just have a couple of lines to write to get the qurcode and to validate the pin code:
using AspNetCore.Totp;
...
// To generate the qrcode/setup key
var totpSetupGenerator = new TotpSetupGenerator();
var totpSetup = totpSetupGenerator.Generate("You app name here", "The username", "YourSuperSecretKeyHere", 300, 300);
string qrCodeImageUrl = totpSetup.QrCodeImage;
string manualEntrySetupCode = totpSetup.ManualSetupKey;
// To validate the pin after user input (where pin is an int variable)
var totpGenerator = new TotpGenerator();
var totpValidator = new TotpValidator(totpGenerator);
bool isCorrectPIN = totpValidator.Validate("YourSuperSecretKeyHere", pin);