简体   繁体   中英

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. I don't see this option in 2010. Is it available and if so how do I get access to it?

The database project format that was included in VS 2005 and VS 2008 has been completely removed in 2010.

Rather than holding loose SQL files that could be run independently, it acts a bit more like a compiler. When the project is built, the SQL files are parsed and (for the most part) turned into an XML-description of the database schema.

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. 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. There is no single set of SQL files you can run - part of the database schema is stored as 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.

If you just want to run a single SQL file or test part of one, open the file, right click, and select "Execute SQL"

DNRTv # 167 talks about VS 2010 Database Projects in detail.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM