Is there a command to check to see if a database exists from Entity Framework?

Will the Database.Exists method work for you?

if (!dbContext.Database.Exists())
    dbContext.Database.Create();

Edit #1 to answer comment

public class DatabaseBootstrapper
{
    private readonly MyContext context;

    public DatabaseBootstrapper(MyContext context)
    {
        this.context = context;
    }

    public void Configure()
    {
        if (context.Database.Exists())
            return;

        context.Database.Create();
        var seeder = new Seeder(context);
        seeder.SeedDatabase();
    }
}

That should do exactly what you want. In your global.asax file...

public void Application_Start()
{
    var context = ...; // get your context somehow.
    new DatabaseBootstrapper(context).Configure();
}

In Entity Framework Core it works like this:

namespace Database
{
    using Microsoft.EntityFrameworkCore.Infrastructure;
    using Microsoft.EntityFrameworkCore.Storage;

    public partial class MyContextClass
    {
        /// <summary>
        /// Checks if database exists
        /// </summary>
        /// <returns></returns>
        public bool Exists()
        {
            return (this.Database.GetService<IDatabaseCreator>() 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