“模型已经有一个元素"使用 Visual Studio 2008 数据库项目 GDR2 时出现错误 (TSD04105)

我正在使用 Visual Studio 2008 数据库项目 GDR2 来管理多个数据库,但我遇到了许多与同义词相关的错误.

I am using Visual Studio 2008 Database Project GDR2 to manage multiple databases and I am getting a number of errors related to synonyms.

Project-A 引用了 Project-B,因为 Project-A 与 Project-B 中的表有许多同义词.我得到的完整错误是TSD04105:模型已经有一个具有相同名称 dbo.[OBJECT]"的元素.这总是指向同义词.

Project-A has a reference to Project-B because Project-A has a number of synonyms to tables in Project-B. The full error I'm getting is "TSD04105: The model already has an element that has the same name dbo.[OBJECT]". This always points at the synonym.

问题似乎是 Project-A 上的同义词与 Project-B 上的表同名.显然,我可以重命名我所有的同义词,以便它们具有与表格不同的名称,但这会为我带来很多工作(到目前为止有 140 多个同义词).

The issue seems to be that the synonym on Project-A has the same name as the table on Project-B. Obviously I could rename all my synonyms so that they have different names than the tables, but this introduces a LOT of work on my part (there's over 140 synonyms so far).

删除对 Project-B 的引用将消除该错误,但我在 Project-A 中的所有存储过程都会生成错误,因为它无法再引用 Project-B 中的表.

Removing the reference to Project-B will get rid of that error, but instead all of my stored procedures in Project-A generate errors because it can't reference the tables in Project-B any more.

除了重命名所有同义词之外,有没有办法解决这个问题?在数据库项目中处理这种情况的适当方法是什么?

Is there a way to fix this problem short of renaming all the synonyms? What is the appropriate way to handle this situation in the Database Project?

推荐答案

我在 2008 服务器项目和数据库项目之间遇到了这个问题,我通过使用文字数据库变量值解决了这个问题.

I had this issue between a 2008 server project and a database project and I solved it by using a literal Database Variable Value.

引用项目属性 -> 引用选项卡 -> 数据库变量值

Referencing project properties -> References Tab -> Database Variable Value

我想说您也可以使用数据库变量名称/值对.

I would say that you could also use a Database Variable Name/Value pair as well.

相关文章