C
C#2mo ago
Saiyanslayer

✅ 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
canton7
canton72mo ago
Migrations are there to change data, too
Saiyanslayer
Saiyanslayer2mo ago
They've failed for me during testing. I've had to manually make changes in the db
canton7
canton72mo ago
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?
Saiyanslayer
Saiyanslayer2mo ago
That's possible. Last two times I had foreign key issues Had to clear the tables for the update to succeed
canton7
canton72mo ago
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
Saiyanslayer
Saiyanslayer2mo ago
Kk thanks!
Want results from more Discord servers?
Add your server