vendredi 8 juillet 2016

Force Entity Framework Code First to Recreate Db that is deleted while application is running

I am currently developing a Web Api project that uses a MySQL backend database for querying. The db access is performed using EF v6.1.3.

What I am trying to achieve is that if my backend database is deleted during the application running, that when the next request for a DB query comes in, the database is recreated to the latest migration and any seeding data inserted.

At the moment when i delete the database as the application is running the next request gets an open db connection error.

If i subsequently recycle the application pool and then retry the request the backend database is created automatically.

Any help in this area would be much appreciated.

Regards,

Stuart

Aucun commentaire:

Enregistrer un commentaire