Entity Framework Core – How to check if database exists?

I have found the solution on my own:

(context.GetService<IDatabaseCreator>() as RelationalDatabaseCreator).Exists()

It works for EF 7.0.0-rc1-final version for SqlServer

UPDATE:

Entity Framework Core 2.0:

(context.Database.GetService<IDatabaseCreator>() as RelationalDatabaseCreator).Exists()

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)