Quantcast
Channel: Entity Framework
Viewing all articles
Browse latest Browse all 10318

Edited Issue: DbContext Contructor doesn't throw "context has changed since the database was created" [853]

$
0
0
After the update from EF 5.0 to EF 6 Alpha 2, our method for DB checking no longer works.

```
try
{
logger.Info("Check if database migration is required");

var context = new MyContext();

logger.Info("No database migration is required");
}
catch (InvalidOperationException ex)
{
// "The model backing the 'MyContext' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269)."
if (ex.Message.Contains("The model backing the 'MyContext' context has changed since the database was created."))
{
logger.Info("Redirect all requests because database migration is required!");
ActivateMaintenanceScreenRoute();
}
else
{
throw;
}
}
```

Have you changed anything on the migration needed detection?

Viewing all articles
Browse latest Browse all 10318

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>