✅ Design patterns or tools to for a changing database?
Hey everyone,
We have an EF core with Blazor project that is nearly ready for users to try out. My concern is how to update the database after reach release. Migrations will help with the database structure, but the existing data may need to be modified if a model changed.
How can I plan to address this? My initial thought is to make a console app to update the database for me, converting the old models to the new ones.
6 Replies
Migrations are there to change data, too
They've failed for me during testing. I've had to manually make changes in the db
That's kinda the point. You walk your schema changes and your data modification together in a controlled way
Failed in what way? Maybe you did it wrong?
That's possible. Last two times I had foreign key issues
Had to clear the tables for the update to succeed
Just to be clear: A migration executes a number of SQL statements to bring the database from one version to another.
If you're trying to change the structure of the database, then trying to naively do that without taking care to modify the data appropriately before and after might fail, sure. But the solution is to come up with a set of SQL statements that you can run in your migration to correctly make that change in a way which doesn't fail.
There's no need to add extra console apps etc. They would have to do the same thing that the migration is supposed to be doing, so just do that in the migration
Kk thanks!