DatabaseFacade.CanConnect Method

Definition

Determines whether or not the database is available and can be connected to.

public virtual bool CanConnect ();
abstract member CanConnect : unit -> bool
override this.CanConnect : unit -> bool
Public Overridable Function CanConnect () As Boolean

Returns

true if the database is available; false otherwise.

Remarks

Any exceptions thrown when attempting to connect are caught and not propagated to the application.

The configured connection string is used to create the connection in the normal way, so all configured options such as timeouts are honored.

Note that being able to connect to the database does not mean that it is up-to-date with regard to schema creation, etc.

See Database connections in EF Core for more information and examples.

Applies to