ASP.NET EntityFramework get database name
For those of you who are using EF core can do this as an alternative:
var databaseName = context.Database.GetDbConnection().Database
This should do the job for you
string databaseName = context.Database.Connection.Database;