I may have worded the question poorly but in my global.asx file i use
if (System.Diagnostics.Debugger.IsAttached)
{
var test = new Test
In Entity Framework Core it works like this:
namespace Database
{
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage;
public partial class MyContextClass
{
///
/// Checks if database exists
///
///
public bool Exists()
{
return (this.Database.GetService() as RelationalDatabaseCreator).Exists();
}
}
}
Make sure the class name equals your database Context class name and is in the same namespace.
Use it like this:
var dbExists = (MyContextClass)db.Exists()
Source: StackOverflow Answer