0

I have a Microsoft SQL Server database project with hundreds of objects (tables, procedures, etc). The resulting database is used in two contexts though -- some customers get a database with all the objects, but some customers' databases contain only a subset of the objects. About 75% of them.

Is there a way to mark each object in the database project in such a way I can say whether it should be deployed or not based on a toggle of some sort?

I thought of a few options:

  1. Use pre/post deploy scripts. I really don't want to do this, as it defeats a lot of the benefits of using a database project in the first place.
  2. Install ALL objects, and have a post-deploy step that deletes the objects that we don't want in the "subset" install. Seem hackish to me.
  3. Break the one database project into two project: one with the required objects and one with the optional.
  4. Have two projects, one with "all" and one with the subset. 75% of the files will appear in both projects. Then I install the appropriate project's database

I think #3 and #4 sound doable, but I'm still hoping there is a simpler, more maintainable solution.

4

1 回答 1

0

看起来正确的方法是创建引用第一个的第二个数据库项目。

数据库 A 将具有所有公共对象,而数据库 B 将具有对数据库 A 的引用(引用 -> 添加数据库引用)。我可以将数据库 A 作为“精简”数据库,或将数据库 B 作为“完整”数据库。

仍在努力,但它似乎是做我想做的最干净和正确的方式。

Microsoft 提供了一个很好的参考,特别是创建一个“复合项目”。https://msdn.microsoft.com/en-us/library/jj684584(v=vs.103).aspx

于 2018-10-11T20:26:46.590 回答