問題描述
我們有以下 SSDT 項目結構:
we have the following SSDT project structure:
DBCore 項目:包括所有非 sql server 版本獨有的對象.
DBCore project: includes all objects that are not sql server edition exclusive.
DBStandardEdition 項目:包括所有標準版特定對象.
DBStandardEdition project: includes all standard edition specific objects.
DBStandardedition 項目引用具有相同數據庫"的 DBCore 項目選項.
The DBStandardedition project references the DBCore project with the "same database" option.
當我直接通過 Visual Studio 將 DBStandardEdition 項目發布到我的演示服務器時,一切正常.所有標準版相關對象均已正確創建.
When I publish the DBStandardEdition project to my demo server via visual studio directly, everything works. All the standard edition related objects are created correctly.
當我使用 Visual Studio 中的架構比較工具將演示服務器上的數據庫與我的 dacpac 文件進行比較時,該工具想要刪除我在 DBStandardEdition 項目中定義的所有對象.我們還有一個使用 DacServices - 類 (DacServices.Deploy) 發布 dacpac 文件的程序.該程序實際上刪除了我的 DBStandardEdition.dacpac 文件中定義的所有內容.
When I compare the database on the demo server to my dacpac file with the schema comparison tool in visual studio, the tool wants to drop all objects I have defined within DBStandardEdition project. We also have a program that publishes the dacpac files with the DacServices - Class (DacServices.Deploy). This program actually drops everything defined in my DBStandardEdition.dacpac file.
我在這里做錯了什么還是一個錯誤?
Am I doing something wrong here or is it a bug?
更新我在我的項目設置中發現了一個問題.我已經設置了構建輸出文件名"將所有數據庫項目設置為相同的值.更改此設置后,Visual Studio 會在我的 DBStandardEdition\Bin\Release 文件夾中生成兩個 DacPac - 文件.DBCore.dacpac 和 DBStandardEdition.dacpac.當我現在使用 Visual Studio 的比較工具將 DBStandardEdition.dacpac 與我的數據庫進行比較(并啟用包括復合對象(僅限數據庫目標)"- 選項)時,一切看起來都不錯.新添加到 DBCore 項目的對象以添加"列出,我的 DBStandardEdition 項目中的所有對象仍然存在.當我激活部署選項包括復合對象..."時,一切部署正常.
Update I figured out a problem in my project settings. I have set the "Build output file name" for all databaseprojects to the same value. After I changed this, Visual Studio generates two DacPac - Files in my DBStandardEdition\Bin\Release Folder. DBCore.dacpac And DBStandardEdition.dacpac. When I now use the compare tool of visual studio to compare the DBStandardEdition.dacpac to my Database (and enable the "Include composite objects (database target only)" - option), all looks good. Newly added objects to DBCore project are listed with "Add", all my objects in my DBStandardEdition projects are still there. When I activate the Deployoption "Include composite objects..." everything deploy fine.
推薦答案
您需要啟用架構比較選項"中的包含復合對象(僅限數據庫目標)"選項.默認情況下這是關閉的,這意味著引用的對象將從比較中排除.
You need to enable the "Include composite objects (database target only)" option in the Schema Compare Options. This is off by default and means that the referenced objects are being excluded from the comparison.
這篇關于SQL Server:當引用另一個 SSDT 項目時,DacPac 會刪除所有內容的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!