I\'m using the Entity Framework with Code First approach. The base class DbContext has functions to create and delete the database as well as to check for its existence.
Assumption: SQL Server
Catching any old exception when querying the DbSet
does not mean the table does not exist.
Querying a DbSet
where the table does not exist will throw an EntityCommandExecutionException
with an inner exception of type SqlException
. That inner exception has an ErrorNumber
property.
Error number 208 reads (source):
Invalid object name '%.*ls'.