SQL Server When publishing database project from Visual Studio, error: "Rows were detected. The schema update is terminating because data loss might occur."

qvk1mo1f  于 2023-11-16  发布在  其他
关注(0)|答案(1)|浏览(93)

I have an existing table in my database and as part of the enhancement, I am required to drop three columns in this table. I have made the corresponding change in the SQL database project that I have in my Visual Studio 2022 where I have removed these columns from the table definition. Now when I publish the project targeting my database, I get this error: "Rows were detected. The schema update is terminating because data loss might occur."

Upon preliminary searching and checking with chatGPT, I got the setting in the project properties -> Debug -> Block incremental deployment if data loss might occur which had to be unchecked.

However, in spite of unchecking this setting, I continue to get this error.

oyxsuwqo

oyxsuwqo1#

Well, it turns out that the project level setting for does not take effect for the publish process. (Curious to know where this project level setting does apply). When publishing, you have to uncheck the value for a similar setting from the publish dialog box.

SQL Database project (right click) -> Publish -> Advanced -> Uncheck "Block incremental deployment if data loss might occur"

Very Important - If you are loading an existing publish profile, ensure that this checkbox is unchecked after you have loaded the publish profile.

相关问题