EF Core 6 - Create table if not exists by means of Add-Migration

Hi, Let's say I've a database with tables A, B and C. When from packet manager console I issue
Add-Migration mig1
Update-Database
Add-Migration mig1
Update-Database
The database is correctly created. Howerver, if later on I add a table D to my DbContext, remove previously created migrations and I run
Add-Migration mig2
Update-Database
Add-Migration mig2
Update-Database
The second command fails with error message
relation "A" already exists
relation "A" already exists
Is there a way to only add not-existing tables (i.e. create if not exists) using migrations?
2 Replies
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
alkasel#159
alkasel#159OP3y ago
Thanks, it worked! it was so simple and I wasted about a day after it... 🤦‍♂️
Want results from more Discord servers?
Add your server