如何在Visual Studio 2012中创建/打开DAC应用程序? [英] How to create/open DAC application in Visual Studio 2012?

查看:168
本文介绍了如何在Visual Studio 2012中创建/打开DAC应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难确定如何使用Visual Studio 2012实际创建或打开DAC应用程序.我正在使用SQL Server2012.已安装SSDT.

I am having a hard time figuring how to actually create or even open a DAC application with Visual Studio 2012. I am using SQL Server 2012. I have SSDT installed.

从Visual Studio创建:

根据联机文档,我应该能够看到名为数据层应用程序"的项目模板,但我所看到的只是SQL Server数据库项目.他们是一样的吗?

According to online documentation I should be able to see a project template with the name "Data Tier Application" but all I see is SQL Server Database Project. Are they the same?

从SSMS创建:

在一个在线视频中,演示者正在使用SSMS->数据库->右键单击->创建项目菜单项,并在向导后弹出一个VS项目.我没有此菜单项,我只有任务->导出为数据层应用程序.这将创建DACPAC文件,而不是VS项目,并且我不知道如何从VS中打开dacpac.

In an online video the presenter is using SSMS -> Database -> Right Click -> Create Project menu item, and after the wizard a VS project is popped open. I do not have this menu item, what I have is Tasks -> Export as Data Tier Application. This creates the DACPAC file but not the VS project, and I could not figure out how to open a dacpac from VS.

推荐答案

DACPAC的目的是提供数据库模式的可移植表示形式,可用于将该模式部署到数据库中,并将其导入数据库中Visual Studio中的项目,并在Schema Compare之类的功能中使用以检查不同源之间的差异.每当您在Visual Studio中构建数据库项目时,都会生成一个.dacpac文件,然后可以将其用于将该项目中定义的架构部署到数据库中.

The purpose of a DACPAC is to provide a portable representation of a database schema, that can be used to deploy that schema to a database, import it into a database project in Visual Studio, and be used in functions like Schema Compare to examine differences between different sources. Whenever you build a database project in Visual Studio a .dacpac file will be generated, and this can then be used to deploy the schema defined in that project to a database.

完整信息的最佳位置是 SSDT帮助,但是我给您一个简短的摘要.

The best place for full information is the SSDT help, but I'll give you a quick summary.

如果您已经拥有DACPAC,则可以通过以下方式在VS中使用它:

If you already have a DACPAC, you can use it in VS in the following ways:

  • 通过在解决方案资源管理器中右键单击项目,然后选择导入->数据层应用程序(* .dacpac)",将模式导入到项目中.然后选择您的dacpac,内容将转换为SQL脚本并添加到项目中.
  • 通过打开SQL Server对象资源管理器,导航到服务器,右键单击数据库并选择发布数据层应用程序...",将dacpac发布到数据库中.这会将DACPAC的内容发布到数据库中在该服务器上.您可以通过右键单击数据库"列表中的数据库来更新数据库.请注意,如果未打开"SQL Server对象资源管理器"视图,则可以选择视图-> SQL Server对象资源管理器"以确保它出现.

要在Visual Studio中创建DACPAC,您可以

To create a DACPAC in Visual Studio, you can

  • 构建一个项目.这会在bin \ Debug目录中创建一个dacpac(假设您以Debug模式构建).
  • 快照项目.这将创建一个dacpac并将其保存在项目中.跟踪数据库架构的时间点版本并将数据库的早期版本与最新定义进行比较非常有用.
  • 在SQL Server对象资源管理器中右键单击数据库,然后选择提取数据层应用程序...".这将创建一个代表数据库内容的dacpac.

最后,我不确定您所观看的视频是什么,但是很可能他们显示了在SQL Server Object Explorer中右键单击数据库并从那里创建项目的情况.这是使用数据库项目开始开发的一种非常常见的方法,因为通常您已经拥有一个包含架构的数据库.通常,最佳实践是使用项目进行开发,并在将其部署到生产服务器等不同环境时使用dacpacs(以及可能的命令行部署工具,例如SqlPackage.exe)(同样,dacpacs非常适合传输架构定义和部署它们)到不同的环境).希望这有助于回答您的问题!

Finally I'm not sure what video you viewed, but it's possible they showed right-clicking on a DB in SQL Server Object Explorer and creating a project from there. That's a very common way to start development using a database project, since often you'll already have a database containing your schema. Generally the best practices would be to develop using a project, and use dacpacs (and possibly command line deployment tools like SqlPackage.exe) when deploying out to different environments such as your production servers (again dacpacs are great for transporting schema definitions and deploying them to different environments). Hope this helps answer your question!

这篇关于如何在Visual Studio 2012中创建/打开DAC应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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