SQL Server:当引用另一个 SSDT 项目时,DacPac 会删除所有内容

时间:2023-02-19
本文介绍了SQL Server:当引用另一个 SSDT 项目时,DacPac 会删除所有内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我们有以下 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 会删除所有内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

上一篇:如何使用开发人员计算机连接到 Azure VM SQL Server 分析服务实例 下一篇:XSD 到 SQL Server 的转换

相关文章

最新文章