Datatier 应用程序在创建数据库时不部署文件组,仅升级过程

Datatier applications not deploying filegroups on creation of database, only upgrade process

当我发布包含多个文件组和文件的新数据库时,文件组不会在创建数据库时发布。当数据库正在升级时它可以工作,这意味着我需要调用 sqlpackager.exe 两次来发布数据库。

Objective: 创建一个包含文件组(共享组件)的数据库,将配置数据与销售数据分开。

实施: 主数据库项目引用仅包含文件组集合的公共数据库项目。数据库引用已正确设置。用于部署 dacpac 的发布文件正确设置了 属性:IgnoreFileGroupPlacement (FALSE) 主数据库项目有一个要添加到文件组的文件列表。 我正在创建一个名为 "defaultworkingspace" 的文件组以将除系统对象之外的所有内容移出主要文件组,我已将此文件组标记为默认文件组。 当我第一次部署时,出现以下错误:

Initializing deployment (Start)
*** A project which specifies SQL Server 2008 as the target platform may experience compatibility issues with SQL Server 2005.
*** The following SqlCmd variables are not defined in the target scripts: SourceCode SourceId.
Initializing deployment (Complete)
Analyzing deployment plan (Start)
Analyzing deployment plan (Complete)
Updating database (Start)
Creating Register_DB...
An error occurred while the batch was being executed.
Updating database (Failed)
*** Could not deploy package.
Warning SQL0: A project which specifies SQL Server 2008 as the target platform may experience compatibility issues with SQL Server 2005.
Warning SQL72013: The following SqlCmd variables are not defined in the target scripts: SourceCode SourceId.
Error SQL72014: .Net SqlClient Data Provider: Msg 5014, Level 16, State 2, Line 1 The filegroup 'DefaultWorkingSpace' does not exist in database 'Register_DB'.
Error SQL72045: Script execution error.  The executed script:
ALTER DATABASE [$(DatabaseName)]
    MODIFY FILEGROUP [DefaultWorkingSpace] DEFAULT;

默认设置已作为 post 部署脚本的一部分进行,因此它应该是 运行 所有 post 部署脚本。当我再次部署它时,现在作为数据库创建的升级

 Initializing deployment (Start)
*** A project which specifies SQL Server 2008 as the target platform may experience compatibility issues with SQL Server 2005.
*** The following SqlCmd variables are not defined in the target scripts: SourceCode SourceId.
*** The source's object [Register_DB] is different than the target's version of the object but the target object will not be updated.
*** The object [Register_DB] already exists in database with a different definition and will not be altered.
Initializing deployment (Complete)
Analyzing deployment plan (Start)
Analyzing deployment plan (Complete)
Updating database (Start)
Creating [Configuration]...
Creating [DefaultWorkingSpace]...
Creating [Giftcards]...
Creating [Logging]...
Creating [MasterData]...
Creating [Mobile]...
Creating [Sales]...
Creating [Config]...
Creating [Working]...
Creating [Giftcards]...
Creating [Logging]...
Creating [Master]...
Creating [Sales]...

升级过程支持文件组,但数据库的初始创建却不支持,这似乎很奇怪...以前有人遇到过这个问题吗?

显然是 dacpac 的已知问题。

我采用的方法是先部署一个数据库项目以掌握并创建数据库,如果它们不存在于该数据库的 post 脚本中。不是最干净的,但现在可以了。