Entity Framework Core - How to check if database exists?

前端 未结 2 505
清歌不尽
清歌不尽 2021-01-01 13:57

For EF6, I can check whether a database exists in the following way:

context.Database.Exists()

How can I do this in EF Core?

2条回答
  •  长情又很酷
    2021-01-01 14:38

    UPDATE .Net Core 3.1

    To check if a database exists and can be contacted:

    dbContext.Database.CanConnect()
    

提交回复
热议问题