4

我们正在使用 Visual Studio 2010,我们的数据库脚本位于数据库项目中。
我们有两个数据库 DB1 和 DB2。DB1 使用 DB2。
我为每个数据库创建了一个数据库项目,并将 DB2 的 .dbschema 文件作为“数据库参考”添加到 DB1 的项目中。所以我在 DB1 中的视图代码就像

CREATE VIEW dbo.myView 
AS 
SELECT * FROM [$(DB2Ref)].dbo.SomeTable
GO 

直到这里一切都很好。但是当我在实际 DB1 数据库和 DB1 数据库项目之间进行模式比较时,比较发现项目中的“myView”和数据库中的“myView”之间存在差异。

有没有办法让架构比较忽略这些引用的数据库变量?

4

1 回答 1

3

Yo can set the Default for the SQL CMD Variable in the project settings to the actual database name. The schema compare in visual studio will then know that there is no change. Unfortunately if you compare against different databases with different names, you'll need to change this Default each time to the database you're comparing to.

Setting SQL Cmd variable Default

SQL Schema Compare of View - the top is without the default defined and thus the object is marked as a change, and the bottom with the variable defined and thus marked as no-action

Sorry not enough rep to add images or more than 3 links yet

于 2016-09-13T08:40:12.293 回答