July 25, 2014

I generated two scripts using Database project in Visual studio - one for updating the database and another for rollback if deployment fails. When I ran the update script, the database updated fine but I ran the rollback script - it failed with the message "Rows were detected. The schema update is terminating because data loss might occur". The issue is somewhat obvious; I have added new fields in a table and if I rollback, meaning if drop those fields then any data in those fields will be lost. So, how can we create script so we can run it. Since the script is needed for rollback, it might be necessary to run it.

To update the settings, open Options from SQL > Schema Compare > Options and then uncheck "Block on possible data loss". Then run the script and it should run fine this time.

image

0 comments:

Reference: Shahed Kazi at AspNetify.com