Visual Studio 2012数据库项目中未解决的参考 [英] Unresolved Reference in Visual Studio 2012 Database Project

查看:117
本文介绍了Visual Studio 2012数据库项目中未解决的参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以直接从我的数据库项目中引用另一个数据库?

Is there a way to reference another database from my database project without directly referencing it?

例如,我希望能够编写如下内容:

For example, I want to be able to write something like this:

CREATE VIEW View1
AS
  SELECT X FROM OtherDB.dbo.Table1

推荐答案

您最好的选择是为您的项目添加数据库引用.对于VS2010和更低版本的DBProj文件,您将需要生成dbschema文件并将其添加为数据库引用.对于SSDT,您需要使用dacpac文件.这对于大多数静态项目非常有效,您甚至可以对其进行裁剪以仅包含相关对象.

Your best bet is to add a database reference to your project. For VS2010 and lower DBProj files, you'll want to generate a dbschema file and add it as a database reference. For SSDT, you'll want to use a dacpac file. This works well for projects that are mostly static and you can even tailor them down to just include the objects that are relevant.

VS2010、2008- http://msdn.microsoft.com/zh-cn/library/dd193283%28v=VS.90%29.aspx 提供了将现有数据库导出到dbschema文件中所需的文档.将其放在您的项目可以访问的位置,并将其添加为数据库参考".

VS2010, 2008 - http://msdn.microsoft.com/en-us/library/dd193283%28v=VS.90%29.aspx has the documentation you'll need to export an existing database into a dbschema file. Place it somewhere your project can access it and add it as a "Database Reference".

SSDT- http://msdn. microsoft.com/en-us/library/hh550080%28v=VS.103%29.aspx 提供了用于生成dacpac文件的命令行参考.生成后,将其放置在您的项目可以访问的位置并添加为数据库引用.

SSDT - http://msdn.microsoft.com/en-us/library/hh550080%28v=VS.103%29.aspx gives you the command line reference for generating a dacpac file. Once generated, place it somewhere your project can access it and add as a database reference.

我在此处有关于SSDT的博客文章: http://schottsql.blogspot.com/2012/10/ssdt-external-database-references.html

I've got a blog post on this for SSDT here: http://schottsql.blogspot.com/2012/10/ssdt-external-database-references.html

这篇关于Visual Studio 2012数据库项目中未解决的参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆