简体   繁体   中英

Create Migration based on current SQL Server schema

Our development team was handed an ASP.NET MVC C# web application from a vendor that has been poorly built and maintained over the years. It started with code first migrations but at some point in time changes were made to the database that were not done with a migration. Now we have a production database with mismatched migrations. My question now, does anyone know of a way to create a migration from the current schema? Kind of like a reverse migration, take the current schema, and create a code first migration for its current state.

If not, open to suggestions as to what steps should be taken to get the migrations to match up with the current production database.

The answer ended up being deleting all previous old migrations, adding a new migration based on current model schema and starting fresh from there. There were still some discrepancies we saw with the production database, like new foreign keys, and lost indexes. But it was a good place to start, and now allows us to spin up the database and run our seeders in new environments.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM