
- VISUAL STUDIO 2017 SQL SERVER DATABASE INITIALIZATION GENERATOR
- VISUAL STUDIO 2017 SQL SERVER DATABASE INITIALIZATION UPDATE
And you don't want to be stuck in that place without a backup.
VISUAL STUDIO 2017 SQL SERVER DATABASE INITIALIZATION GENERATOR
While the EF code generator is pretty good at matching the EF schema and what's in your database, in some cases it doesn't work. If you go the route of resetting your migrations, make sure you back up your code and make known good backups of your database, just in case the schema reversion doesn't do what you expect. There's no built-in way to do this, so you have to perform a number of manual steps and that's what this post is about. That might mean rolling back to the last known good migration.Īs you might expect, resetting migrations is not as obvious as it could be – it's not use case that Entity Framework expects you to work with.

Usually this isn't a problem as databases tend to be vital in order for anything to work so they are very likely to be up date, but if not you'll have to find that consistent state so that your EF schema and the database are in sync. To be clear this works only if all of your databases are up to date in the first place or at least in some known consistent state. I've found in most cases it's simply easier to blow away the migrations and start with a clean slate from the current schema. There are a number of hacks you can try to fix bonked migrations, but to be honest more often than not those simply don't work.
VISUAL STUDIO 2017 SQL SERVER DATABASE INITIALIZATION UPDATE
Usually this happens after a large number of migrations have been applied and I get stuck to where I can't update a database with new migrations or roll back. Not sure if this is a common occurrence, but I've had a number of occasions where Entity Framework migrations have left the state of migrations in an unusable state.
