简体   繁体   English

数据库项目:Visual Studio 2008与2010

[英]Database Projects: Visual Studio 2008 vs 2010

I just installed VS 2010 for the purposes of running someone else's DB project that was created using the 2010. In VS 2008 I was able to right click on a SQL file ans select "Run ON" to run the script on a given SQL Server. 我只是安装VS 2010,目的是运行使用2010创建的其他人的数据库项目。在VS 2008中,我可以右键单击SQL文件,然后选择“运行”以在给定的SQL Server上运行脚本。 I don't see this option in 2010. Is it available and if so how do I get access to it? 我在2010年没有看到此选项。它可用吗?如果可以,我如何获得它?

The database project format that was included in VS 2005 and VS 2008 has been completely removed in 2010. VS 2005和VS 2008中包含的数据库项目格式已在2010年被完全删除。

Rather than holding loose SQL files that could be run independently, it acts a bit more like a compiler. 与其持有可以独立运行的松散SQL文件,它的行为有点像编译器。 When the project is built, the SQL files are parsed and (for the most part) turned into an XML-description of the database schema. 在构建项目时,将对SQL文件进行解析,并在大多数情况下将其转换为数据库模式的XML描述。

If you're trying to create or update a database based on all of the scripts in the project, right click on the project name in Solution Explorer and select "Properties". 如果您试图基于项目中的所有脚本创建或更新数据库,请在解决方案资源管理器中右键单击项目名称,然后选择“属性”。 Under the Deploy tab youchange "Deploy Action" to "Create a deployment script and deploy to the database". 在“部署”选项卡下,将“部署操作”更改为“创建部署脚本并部署到数据库”。 Specify the connection settings and database name. 指定连接设置和数据库名称。

When you select "Deploy" on the right-click context menu of the database project, Visual Studio will build the database deployment files and generate the database. 当您在数据库项目的右键单击上下文菜单上选择“部署”时,Visual Studio将生成数据库部署文件并生成数据库。 It's generally intelligent enough to update existing databases as well, assuming the project was designed well. 假设项目设计得当,它通常也足够智能以更新现有数据库。

If you're attempting a remote deployment to a production SQL Server, things get a bit trickier. 如果您尝试将远程部署到生产SQL Server,则事情会变得有些棘手。 There is no single set of SQL files you can run - part of the database schema is stored as XML. 您无法运行任何一组SQL文件-数据库模式的一部分存储为XML。

Take a look at http://blogs.msdn.com/b/gertd/archive/2009/06/05/declarative-database-development.aspx - it describes how to use the "vsdbcmd.exe" utility to deploy a database file. 看看http://blogs.msdn.com/b/gertd/archive/2009/06/05/declarative-database-development.aspx-它描述了如何使用“ vsdbcmd.exe”实用程序来部署数据库文件。

If you just want to run a single SQL file or test part of one, open the file, right click, and select "Execute SQL" 如果您只想运行一个SQL文件或测试其中的一部分,请打开该文件,右键单击,然后选择“执行SQL”

DNRTv # 167 talks about VS 2010 Database Projects in detail. DNRTv#167详细讨论了VS 2010数据库项目。

As @ShadowChaser already mentioned, DB Project in VS 2008 simply had the scripts in it, and 2010 version is a lot more complex and has a lot more features. 正如@ShadowChaser已经提到的那样,VS 2008中的DB Project只是其中包含了脚本,而2010版本则更加复杂并且具有更多功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将数据库SQL Server 2008链接到Visual Studio 2010 - Linked database sql server 2008 to visual studio 2010 Visual Studio'SQL Server 2008 Server Project'与'Sql Server 2008数据库项目'? - Visual Studio 'SQL Server 2008 Server Project' vs. 'Sql Server 2008 Database project'? 将Microsoft Visual Studio 2010连接到SQL Server 2008 R2数据库 - Connect Microsoft Visual Studio 2010 to SQL Server 2008 R2 database 无法将在VS2010中创建的数据库附加到SQL Server Studio 2008 R2 - Cannot attach database created in VS2010 to SQL Server studio 2008 r2 有没有办法将商业智能项目模板添加到Visual Studio 2008? - Is there a way to add Business Intelligence Projects templates to Visual Studio 2008? 如何在Visual Studio 2010中使用phpmyadmin数据库? - how to use phpmyadmin database in visual studio 2010? 具有用户的Visual Studio 2010基于服务的数据库 - Visual Studio 2010 Service Based Database With Users Visual Studio 2010中数据库的连接字符串 - connection strings of database in visual studio 2010 使用Visual Studio 2010对数据库进行写访问 - Write access to a database using Visual Studio 2010 插入数据库LINQ to SQL Visual Basic Visual Studio 2008 - Inserting into database LINQ to SQL Visual Basic Visual Studio 2008
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM