如何:将 Visual Studio 2010 数据库项目转换为 SQL Server 数据库项目并重新以不同平台为目标How to: Convert a Visual Studio 2010 Database Projects to SQL Server Database Projects and Retarget to a Different Platform

在 SQL Server Data Tools (SSDT) 中,可以将在 Visual Studio 2010 中创建的现有 SQL Server 数据库、CLR 和数据层应用程序项目转换为新的 SQL Server 数据库项目。In SQL Server Data Tools (SSDT), you can convert existing SQL Server Database, CLR, and Data-Tier Application projects created in Visual Studio 2010 to the new SQL Server database project. 通过这样做,你可以利用 SSDT 提供的新的数据库开发体验(例如更新的 Transact-SQL 编辑体验),并且能够通过代码验证将项目重新针对 Microsoft SQL Server 2012 和 SQL Azure 进行设计。By doing so, you can take advantage of the new database development experience that SSDT provides, such as an updated Transact-SQL editing experience, and the ability to retarget your project to Microsoft SQL Server 2012 and SQL Azure with code validation. 该转换过程转换在 SSDT 中具有等效类型的对象(表、视图、存储过程、属性文件或脚本),包括其权限和 DAC 策略文件。The conversion process converts objects (table, views, stored-procedures, property files, or scripts) that have an equivalent type in SSDT, including their permissions and DAC policy files. 无法转换的项目在转换日志报告中突出显示。Artifacts that cannot be converted are highlighted in a conversion log report.

下表列出可由 SSDT 转换或者不能由 SSDT 转换的所有项目项。The following table lists all the project artifacts that can or cannot be converted by SSDT.

可以转换的项目项Project artifacts that can be converted 不能转换的项目项Project artifacts that cannot be converted
项目文件Project Files

.dbproj(Visual Studio 2010 数据库和服务器项目、数据层应用程序项目)项目文件.dbproj (Visual Studio 2010 Database and Server projects, Data-Tier Application projects) project files

.csproj 和 .vbproj CLR 项目文件可转换,但可能导致数据丢失.csproj and .vbproj CLR project files can be converted, but may result in data loss
数据库单元测试项目Database Unit Test Projects

.files 项之类的部分项目Partial Projects such as .files items
属性文件Properties Files

*.sqldeployment、.sqlsettings 和 .sqlpolicy 文件将转换为其对应的项目属性页*.sqldeployment, .sqlsettings, and .sqlpolicy files are converted to their corresponding Project Property pages

.sqlpermissions 文件将转换为 Transact-SQL 脚本.sqlpermissions files are converted to Transact-SQL scripts
项目属性Project Properties

Server.sqlsettingsServer.sqlsettings

在 .sqlcmd 文件中定义的 SQLCMD 变量SQLCMD variables defined in .sqlcmd files
使用其现有的文件夹结构导入 .sql 文件。.sql files are imported using their existing folder structure. 扩展性文件。Extensibility files.
预先部署和后期部署脚本Pre-Deployment and Post-Deployment scripts 在项目转换后必须手动重新建立数据库引用。Database references will have to manually re-established after project conversion.
架构比较文件Schema Compare files 数据生成文件。Data Generation files.

转换项目To convert a project

  1. 打开 SQL Server 2005 或 2008 数据库项目。Open a SQL Server 2005 or 2008 Database Project.

  2. “转换为 SQL Server 数据库项目” 向导将自动打开。The Convert to SQL Server Database project wizard automatically opens. 选择“转换为 SQL Server 数据库项目” ,然后单击“确定” 。Select Convert to SQL Server Database project and click OK. 保留默认设置以便备份选中的现有文件。Keep the default setting to backup existing files checked.

  3. 将自动生成一个转换报告,其中列出已转换的所有文件。A conversion report is automatically generated, listing all files that have been converted. 要了解有关转换过程的详细信息,请单击项目文件名旁边的 +(加号)。To read more information about the conversion process, click the + sign next to the project filename.

  4. 请注意,在“解决方案资源管理器” 中,项目文件、属性文件和架构对象都将转换。Notice that in Solution Explorer, project file, property files, and schema objects are all converted.

更改项目的目标平台To change a project's target platform

  1. 在“解决方案资源管理器” 中,右键单击新转换的项目,然后选择“属性” 以便访问“项目设置” 对话框。Right-click your newly converted project in Solution Explorer and select Properties to access the Project Settings dialog box.

  2. 在“目标平台” 下拉列表中选择任何 SSDT 支持的平台。Select any of the SSDT-supported platforms in the Target platform dropdown list.

另请参阅See Also

如何:更改目标平台并发布数据库项目How to: Change Target Platform and Publish a Database Project